Class: ZLocalize::ConditionalExpression
- Inherits:
-
Expression
- Object
- Expression
- ZLocalize::ConditionalExpression
- Defined in:
- lib/zlocalize/rdoc_source_parser.rb
Overview
represents an ‘inline-if’ expression, as in:
something ? when_true : when_false
Instance Attribute Summary collapse
-
#condition ⇒ Object
:nodoc: all.
-
#false_expr ⇒ Object
Returns the value of attribute false_expr.
-
#true_expr ⇒ Object
Returns the value of attribute true_expr.
Attributes inherited from Expression
#char_no, #line_no, #sub_method, #text
Instance Method Summary collapse
- #display(indent = 0) ⇒ Object
-
#initialize(line_to, char_no) ⇒ ConditionalExpression
constructor
A new instance of ConditionalExpression.
- #to_entry_string ⇒ Object
- #to_translation_entry(filename) ⇒ Object
Methods inherited from Expression
#is_translate_call, #prefix, #set_text
Constructor Details
#initialize(line_to, char_no) ⇒ ConditionalExpression
Returns a new instance of ConditionalExpression.
307 308 309 |
# File 'lib/zlocalize/rdoc_source_parser.rb', line 307 def initialize(line_to,char_no) super(line_to,char_no,'?') end |
Instance Attribute Details
#condition ⇒ Object
:nodoc: all
303 304 305 |
# File 'lib/zlocalize/rdoc_source_parser.rb', line 303 def condition @condition end |
#false_expr ⇒ Object
Returns the value of attribute false_expr.
305 306 307 |
# File 'lib/zlocalize/rdoc_source_parser.rb', line 305 def false_expr @false_expr end |
#true_expr ⇒ Object
Returns the value of attribute true_expr.
304 305 306 |
# File 'lib/zlocalize/rdoc_source_parser.rb', line 304 def true_expr @true_expr end |
Instance Method Details
#display(indent = 0) ⇒ Object
311 312 313 314 315 316 317 318 319 320 |
# File 'lib/zlocalize/rdoc_source_parser.rb', line 311 def display(indent = 0) i = prefix(indent) + "#{self.class.name} (#{line_no},#{char_no})\n" i << prefix(indent+1) + "condition:\n" i << @condition.display(indent+2) i << prefix(indent+1) + "when true:\n" i << @true_expr.display(indent+2) i << prefix(indent+1) + "when false:\n" i << @false_expr.display(indent+2) i end |
#to_entry_string ⇒ Object
328 329 330 |
# File 'lib/zlocalize/rdoc_source_parser.rb', line 328 def to_entry_string "#{conditions.as_entry_string} ? #{true_expr.as_entry_string} : #{false_expr.as_entry_string}".force_encoding("UTF-8") end |
#to_translation_entry(filename) ⇒ Object
322 323 324 325 326 |
# File 'lib/zlocalize/rdoc_source_parser.rb', line 322 def to_translation_entry(filename) [condition.to_translation_entry(filename), true_expr.to_translation_entry(filename), false_expr.to_translation_entry(filename)].flatten.compact end |