diff --git a/lib/rdf/model/value.rb b/lib/rdf/model/value.rb index 528c2ffb..a09b1ba9 100644 --- a/lib/rdf/model/value.rb +++ b/lib/rdf/model/value.rb @@ -197,19 +197,20 @@ def validate! alias_method :validate, :validate! ## - # Returns `true` if this Value starts with the given `string`. + # Returns `true` if this Value starts with any of the given strings. # # @example # RDF::URI('http://example.org/').start_with?('http') #=> true # RDF::Node('_:foo').start_with?('_:bar') #=> false # RDF::Litera('Apple').start_with?('Orange') #=> false + # RDF::Litera('Apple').start_with?('Orange', 'Apple') #=> true # - # @param [String, #to_s] string + # @param [Array<#to_s>] *args Any number of strings to check against. # @return [Boolean] `true` or `false` # @see String#start_with? # @since 0.3.0 - def start_with?(string) - to_s.start_with?(string.to_s) + def start_with?(*args) + to_s.start_with?(*args.map(&:to_s)) end alias_method :starts_with?, :start_with? diff --git a/spec/model_literal_spec.rb b/spec/model_literal_spec.rb index 98f83713..1cc024bf 100644 --- a/spec/model_literal_spec.rb +++ b/spec/model_literal_spec.rb @@ -195,6 +195,7 @@ def self.literals(*selector) it "#start_with?" do expect(RDF::Literal('foo')).to be_start_with('foo') expect(RDF::Literal('bar')).not_to be_start_with('foo') + expect(RDF::Literal('foo')).to be_start_with('foo', 'nope') end describe "#==" do