Method: CSL::Locale::Terms#store

Defined in:
lib/csl/locale/term.rb

#store(term, translation = nil, options = nil) ⇒ self

Shorthand method to stores a new term translations.

Examples:

terms.store(term)
terms.store('book', ['book', 'books'])
terms.store('book', 'bk', :form => 'short')

Parameters:

  • the (Term, String)

    term; or the the term’s name

  • the (String)

    term’s translation

  • additional (Hash)

    term attributes

Returns:

  • (self)


36
37
38
39
40
41
42
43
44
# File 'lib/csl/locale/term.rb', line 36

def store(term, translation = nil, options = nil)
  unless term.is_a?(Term)
    term = Term.new(:name => term)
    term.attributes.merge(options) unless options.nil?
    term.set(*translation)
  end

  self << term
end