lib/csl/locale.rb in csl-1.3.2 vs lib/csl/locale.rb in csl-1.4.0
- old
+ new
@@ -99,17 +99,17 @@
# additionally accepts a hash of localize style-options. The fourth form
# is the standard node attribute initialize signature.
def initialize(*arguments)
case arguments.length
when 0
- locale, attributes, options = Locale.default, {}, nil
+ locale, attributes, options = nil, {}, nil
when 1
if arguments[0].is_a?(Hash)
arguments[0] = arguments[0].symbolize_keys
locale = arguments[0].delete(:lang) ||
- arguments[0].delete(:'xml:lang') || Locale.default
+ arguments[0].delete(:'xml:lang')
attributes, options = arguments
else
attributes, locale, options = {}, *arguments
end
@@ -369,10 +369,21 @@
# language for its region
def default_language?
language && language == Locale.languages[region]
end
+ def like?(other)
+ return false unless other.is_a? Locale
+ return true if universal? || other.universal?
+
+ language == other.language
+ end
+
+ def universal?
+ language.nil?
+ end
+
def validate
Schema.validate self
end
def valid?
@@ -387,10 +398,11 @@
# @return [self]
def merge!(*others)
others.each do |other|
merge_options other
merge_dates other
+ merge_terms other
end
self
end
@@ -479,9 +491,19 @@
end
else
other.each_date do |date|
add_child date.deep_copy
end
+ end
+
+ self
+ end
+
+ def merge_terms(other)
+ return self unless other.has_terms?
+
+ other.each_term do |term|
+ store term.deep_copy
end
self
end
end