Skip to content

Commit

Permalink
Merge 59a6def into 3d2f8a1
Browse files Browse the repository at this point in the history
  • Loading branch information
pcl-code committed Oct 13, 2020
2 parents 3d2f8a1 + 59a6def commit 86b7ec6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/bibtex/entry.rb
Expand Up @@ -662,6 +662,7 @@ def to_rdf(_options = {})

alias to_bibo to_rdf

undef_method :year
def year
return fields[:year] if has_field?(:year)
return unless has_field?(:date)
Expand Down
7 changes: 7 additions & 0 deletions lib/bibtex/value.rb
Expand Up @@ -116,10 +116,12 @@ def add(argument)
self
end

undef_method :<<
alias << add
alias push add

%i[strip! upcase! downcase! sub! gsub! chop! chomp! rstrip!].each do |method_id|
undef_method method_id
define_method(method_id) do |*arguments, &block|
@tokens.each do |part|
part&.send(method_id, *arguments, &block)
Expand All @@ -128,6 +130,7 @@ def add(argument)
end
end

undef_method :replace
def replace(*arguments)
return self unless has_symbol?

Expand Down Expand Up @@ -162,6 +165,7 @@ def join(separator = '')
self
end

undef_method :to_s
# call-seq:
# Value.new('foo').to_s #=> "foo"
# Value.new(:foo).to_s #=> "foo"
Expand Down Expand Up @@ -206,6 +210,7 @@ def value

alias v value

undef_method :inspect
def inspect
"#<#{self.class} #{@tokens.map(&:inspect).join(', ')}>"
end
Expand Down Expand Up @@ -246,6 +251,7 @@ def numeric?
atomic? && @tokens[0] =~ /^\s*[+-]?\d+\s*$/
end

undef_method :to_i
def to_i
@tokens[0].to_i
end
Expand Down Expand Up @@ -293,6 +299,7 @@ def respond_to?(method, include_all = false)
method =~ /^(?:convert|from)_([a-z]+)(!)?$/ || super
end

undef_method :<=>
def <=>(other)
if numeric? && other.respond_to?(:numeric?) && other.numeric?
to_i <=> other.to_i
Expand Down

0 comments on commit 86b7ec6

Please sign in to comment.