Class: MessageFormat::Compiler

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

Defined Under Namespace

Classes: CompileError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale, messages, strict: true) ⇒ Compiler

Returns a new instance of Compiler.



17
18
19
20
21
22
# File 'lib/messageformat.rb', line 17

def initialize(locale, messages, strict: true)
  @locale = locale
  @messages = messages
  @strict = strict
  @context = init_context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



15
16
17
# File 'lib/messageformat.rb', line 15

def context
  @context
end

#localeObject (readonly)

Returns the value of attribute locale.



15
16
17
# File 'lib/messageformat.rb', line 15

def locale
  @locale
end

#messagesObject (readonly)

Returns the value of attribute messages.



15
16
17
# File 'lib/messageformat.rb', line 15

def messages
  @messages
end

#strictObject (readonly)

Returns the value of attribute strict.



15
16
17
# File 'lib/messageformat.rb', line 15

def strict
  @strict
end

Instance Method Details

#compileObject



24
25
26
27
28
# File 'lib/messageformat.rb', line 24

def compile
  context.call("compileMessageFormat", locale, messages, strict)
rescue MiniRacer::RuntimeError => e
  raise CompileError.new(cause: e)
end