Method: CSL::Locale#initialize
- Defined in:
- lib/csl/locale.rb
#initialize(*arguments) {|_self| ... } ⇒ Locale
Returns a new locale. In the first form, the language/regions is set to the default language and region. In the second form the language/region is set by the passed-in IETF tag. The third form additionally accepts a hash of localize style-options. The fourth form is the standard node attribute initialize signature.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/csl/locale.rb', line 105 def initialize(*arguments) case arguments.length when 0 locale, attributes, = Locale.default, {}, 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 attributes, = arguments else attributes, locale, = {}, *arguments end when 2 attributes, locale, = {}, *arguments else raise ArgumentError, "wrong number of arguments (#{arguments.length} for 0..2)" end super(attributes, &nil) set(locale) unless locale.nil? unless .nil? children[:'style-options'] = StyleOptions.new() end yield self if block_given? end |