Class: ZLocalize::OperatorExpression

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

Overview

an Operator expression holds the operator itself, and the operands

Instance Attribute Summary collapse

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, op) ⇒ OperatorExpression

Returns a new instance of OperatorExpression.



277
278
279
280
281
# File 'lib/zlocalize/rdoc_source_parser.rb', line 277

def initialize(line_no,char_no,op)
  super(line_no,char_no,op)
  @operands = []
  @operator = op
end

Instance Attribute Details

#operandsObject

Returns the value of attribute operands.



275
276
277
# File 'lib/zlocalize/rdoc_source_parser.rb', line 275

def operands
  @operands
end

#operatorObject

:nodoc: all



274
275
276
# File 'lib/zlocalize/rdoc_source_parser.rb', line 274

def operator
  @operator
end

Instance Method Details

#display(indent = 0) ⇒ Object



283
284
285
286
287
288
# File 'lib/zlocalize/rdoc_source_parser.rb', line 283

def display(indent = 0)
  p = prefix(indent)
  i = p + "#{self.class.name} (#{line_no},#{char_no})\n"
  @operands.each { |o| i << o.display(indent+1) }
  i
end

#to_entry_stringObject



294
295
296
# File 'lib/zlocalize/rdoc_source_parser.rb', line 294

def to_entry_string
  @operands.collect { |o| o.to_entry_string }.join(" #{@operator} ").force_encoding("UTF-8")
end

#to_translation_entry(filename) ⇒ Object



290
291
292
# File 'lib/zlocalize/rdoc_source_parser.rb', line 290

def to_translation_entry(filename)
  @operands.collect { |o| o.to_translation_entry(filename) }.flatten.compact
end