File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -673,22 +673,6 @@ def freeze
673673 self
674674 end
675675
676- ##
677- # Returns `true` if this URI starts with the given `string`.
678- #
679- # @example
680- # RDF::URI('http://example.org/').start_with?('http') #=> true
681- # RDF::URI('http://example.org/').start_with?('ftp') #=> false
682- #
683- # @param [String, #to_s] string
684- # @return [Boolean] `true` or `false`
685- # @see String#start_with?
686- # @since 0.3.0
687- def start_with? ( string )
688- to_s . start_with? ( string . to_s )
689- end
690- alias_method :starts_with? , :start_with?
691-
692676 ##
693677 # Returns `true` if this URI ends with the given `string`.
694678 #
Original file line number Diff line number Diff line change @@ -159,6 +159,23 @@ def validate!
159159 end
160160 alias_method :validate , :validate!
161161
162+ ##
163+ # Returns `true` if this Value starts with the given `string`.
164+ #
165+ # @example
166+ # RDF::URI('http://example.org/').start_with?('http') #=> true
167+ # RDF::Node('_:foo').start_with?('_:bar') #=> false
168+ # RDF::Litera('Apple').start_with?('Orange') #=> false
169+ #
170+ # @param [String, #to_s] string
171+ # @return [Boolean] `true` or `false`
172+ # @see String#start_with?
173+ # @since 0.3.0
174+ def start_with? ( string )
175+ to_s . start_with? ( string . to_s )
176+ end
177+ alias_method :starts_with? , :start_with?
178+
162179 ##
163180 # Returns a copy of this value converted into its canonical
164181 # representation.
Original file line number Diff line number Diff line change @@ -155,6 +155,11 @@ def self.literals(*selector)
155155 end
156156 end
157157
158+ it "#start_with?" do
159+ expect ( RDF ::Literal ( 'foo' ) ) . to be_start_with ( 'foo' )
160+ expect ( RDF ::Literal ( 'bar' ) ) . not_to be_start_with ( 'foo' )
161+ end
162+
158163 describe "#==" do
159164 literals ( :all_plain ) . each do |args |
160165 it "returns true for #{ args . inspect } " do
Original file line number Diff line number Diff line change 5656 specify { expect ( RDF ::Node . intern ( :a ) ) . to eql RDF ::Node . intern ( "a" ) }
5757 end
5858
59+ it "#start_with?" do
60+ expect ( RDF ::Node ( 'foo' ) ) . to be_start_with ( '_:foo' )
61+ expect ( RDF ::Node ( 'bar' ) ) . not_to be_start_with ( '_:foo' )
62+ end
63+
5964 subject { new . call ( "foo" ) }
6065
6166 describe "#dup" do
You can’t perform that action at this time.
0 commit comments