Class: ZLocalize::ArrayExpression

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

Overview

an Array declaration. It will hold its elements as a list of Expressions

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) ⇒ ArrayExpression

Returns a new instance of ArrayExpression.



192
193
194
195
# File 'lib/zlocalize/source_parser.rb', line 192

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

Instance Attribute Details

#elementsObject

:nodoc: all



190
191
192
# File 'lib/zlocalize/source_parser.rb', line 190

def elements
  @elements
end

Instance Method Details

#display(indent = 0) ⇒ Object



197
198
199
200
201
# File 'lib/zlocalize/source_parser.rb', line 197

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

#to_entry_stringObject



207
208
209
210
# File 'lib/zlocalize/source_parser.rb', line 207

def to_entry_string
  @elements.collect { |e| e.to_entry_string }
  # '[' + @elements.collect { |e| e.to_entry_string }.join(', ') + ']'
end

#to_translation_entry(filename) ⇒ Object



203
204
205
# File 'lib/zlocalize/source_parser.rb', line 203

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