Class: ZLocalize::ConditionalExpression
- Inherits:
-
Expression
- Object
- Expression
- ZLocalize::ConditionalExpression
- Defined in:
- lib/zlocalize/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.
303 304 305 |
# File 'lib/zlocalize/source_parser.rb', line 303 def initialize(line_to,char_no) super(line_to,char_no,'?') end |
Instance Attribute Details
#condition ⇒ Object
:nodoc: all
299 300 301 |
# File 'lib/zlocalize/source_parser.rb', line 299 def condition @condition end |
#false_expr ⇒ Object
Returns the value of attribute false_expr.
301 302 303 |
# File 'lib/zlocalize/source_parser.rb', line 301 def false_expr @false_expr end |
#true_expr ⇒ Object
Returns the value of attribute true_expr.
300 301 302 |
# File 'lib/zlocalize/source_parser.rb', line 300 def true_expr @true_expr end |
Instance Method Details
#display(indent = 0) ⇒ Object
307 308 309 310 311 312 313 314 315 316 |
# File 'lib/zlocalize/source_parser.rb', line 307 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
324 325 326 |
# File 'lib/zlocalize/source_parser.rb', line 324 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
318 319 320 321 322 |
# File 'lib/zlocalize/source_parser.rb', line 318 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 |