Class: MessageFormat::MessageFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/message_format.rb

Instance Method Summary collapse

Constructor Details

#initialize(pattern, locale = nil) ⇒ MessageFormat

Returns a new instance of MessageFormat.



9
10
11
12
13
14
15
# File 'lib/message_format.rb', line 9

def initialize ( pattern, locale=nil )
  @locale = (locale || TwitterCldr.locale).to_sym
  @format = Interpreter.interpret(
    Parser.parse(pattern),
    { :locale => @locale }
  )
end

Instance Method Details

#format(args = nil) ⇒ Object



17
18
19
# File 'lib/message_format.rb', line 17

def format ( args=nil )
  @format.call(args)
end