Class: ZLocalize::HashExpression

Inherits:
IdentifierExpression show all
Defined in:
lib/zlocalize/rdoc_source_parser.rb

Overview

a Hash declaration. Elements will be a Hash in which each element will itself be a HashElementExpression like this:

{ :key => Expression, :value => Expression }

Instance Attribute Summary collapse

Attributes inherited from IdentifierExpression

#name, #parameters

Attributes inherited from Expression

#char_no, #line_no, #sub_method, #text

Instance Method Summary collapse

Methods inherited from Expression

#is_translate_call, #prefix, #set_text

Constructor Details

#initialize(line_no, char_no) ⇒ HashExpression

Returns a new instance of HashExpression.



225
226
227
228
# File 'lib/zlocalize/rdoc_source_parser.rb', line 225

def initialize(line_no,char_no)
  super(line_no,char_no,'hash')
  @elements = []
end

Instance Attribute Details

#elementsObject

:nodoc: all



223
224
225
# File 'lib/zlocalize/rdoc_source_parser.rb', line 223

def elements
  @elements
end

Instance Method Details

#display(indent = 0) ⇒ Object



230
231
232
233
234
# File 'lib/zlocalize/rdoc_source_parser.rb', line 230

def display(indent = 0)
  i = super(indent)
  @elements.each { |e| i << e.display(indent) }
  i
end

#to_entry_stringObject



240
241
242
# File 'lib/zlocalize/rdoc_source_parser.rb', line 240

def to_entry_string
  '{ ' + @elements.collect { |e| e.to_entry_string }.compact.join(',') + ' }'.force_encoding("UTF-8")
end

#to_translation_entry(filename) ⇒ Object



236
237
238
# File 'lib/zlocalize/rdoc_source_parser.rb', line 236

def to_translation_entry(filename)
  @elements.collect { |elem| elem.to_translation_entry(filename) }.flatten.compact
end