Class: ZLocalize::HashElementExpression

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

Overview

a Hash Element. It holds the key and the value of the element as 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) ⇒ HashElementExpression

Returns a new instance of HashElementExpression.



251
252
253
# File 'lib/zlocalize/rdoc_source_parser.rb', line 251

def initialize(line_no,char_no)
  super(line_no,char_no,'hashElement')
end

Instance Attribute Details

#keyObject

:nodoc: all



248
249
250
# File 'lib/zlocalize/rdoc_source_parser.rb', line 248

def key
  @key
end

#valueObject

Returns the value of attribute value.



249
250
251
# File 'lib/zlocalize/rdoc_source_parser.rb', line 249

def value
  @value
end

Instance Method Details

#display(indent = 0) ⇒ Object



255
256
257
258
259
# File 'lib/zlocalize/rdoc_source_parser.rb', line 255

def display(indent = 0)
  i = super(indent)
  i << prefix(indent) + "key:\n" + @key.display(indent+1)
  i << prefix(indent) + "value:\n" + @value.display(indent+1)
end

#to_entry_stringObject



265
266
267
# File 'lib/zlocalize/rdoc_source_parser.rb', line 265

def to_entry_string
  "#{key.to_entry_string} => #{value.to_entry_string}".force_encoding("UTF-8")
end

#to_translation_entry(filename) ⇒ Object



261
262
263
# File 'lib/zlocalize/rdoc_source_parser.rb', line 261

def to_translation_entry(filename)
  r = [key.to_translation_entry(filename),value.to_translation_entry(filename)].flatten.compact
end