Class: ZLocalize::Expression
- Inherits:
-
Object
- Object
- ZLocalize::Expression
- Defined in:
- lib/zlocalize/source_parser.rb
Overview
base class for Expressions we’re interested in
Direct Known Subclasses
ConditionalExpression, DontCareExpression, IdentifierExpression, OperatorExpression
Instance Attribute Summary collapse
-
#char_no ⇒ Object
Returns the value of attribute char_no.
-
#line_no ⇒ Object
:nodoc: all.
-
#sub_method ⇒ Object
Returns the value of attribute sub_method.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#display(indent = 0) ⇒ Object
display this Expression as a string.
-
#initialize(line_no, char_no, text = '') ⇒ Expression
constructor
A new instance of Expression.
- #is_translate_call ⇒ Object
-
#prefix(indent) ⇒ Object
puts spaces before the output generated by
display
. - #set_text(t) ⇒ Object
- #to_entry_string ⇒ Object
-
#to_translation_entry(filename) ⇒ Object
Since Expression is an abstract class, no output is generated (descendants redefine this method).
Constructor Details
#initialize(line_no, char_no, text = '') ⇒ Expression
Returns a new instance of Expression.
18 19 20 |
# File 'lib/zlocalize/source_parser.rb', line 18 def initialize(line_no,char_no,text = '') @line_no, @char_no, @text = line_no, char_no, text end |
Instance Attribute Details
#char_no ⇒ Object
Returns the value of attribute char_no.
14 15 16 |
# File 'lib/zlocalize/source_parser.rb', line 14 def char_no @char_no end |
#line_no ⇒ Object
:nodoc: all
13 14 15 |
# File 'lib/zlocalize/source_parser.rb', line 13 def line_no @line_no end |
#sub_method ⇒ Object
Returns the value of attribute sub_method.
16 17 18 |
# File 'lib/zlocalize/source_parser.rb', line 16 def sub_method @sub_method end |
#text ⇒ Object
Returns the value of attribute text.
15 16 17 |
# File 'lib/zlocalize/source_parser.rb', line 15 def text @text end |
Instance Method Details
#display(indent = 0) ⇒ Object
display this Expression as a string. Used for debugging purposes
33 34 35 36 |
# File 'lib/zlocalize/source_parser.rb', line 33 def display(indent = 0) i = prefix(indent) i << "#{self.class.name} (#{line_no},#{char_no}): #{@text}\n" end |
#is_translate_call ⇒ Object
48 49 50 |
# File 'lib/zlocalize/source_parser.rb', line 48 def is_translate_call false end |
#prefix(indent) ⇒ Object
puts spaces before the output generated by display
. Used for debugging purposes.
28 29 30 |
# File 'lib/zlocalize/source_parser.rb', line 28 def prefix(indent) ' ' * (indent*INDENT_STEP) end |
#set_text(t) ⇒ Object
22 23 24 25 |
# File 'lib/zlocalize/source_parser.rb', line 22 def set_text(t) @text = t self end |
#to_entry_string ⇒ Object
44 45 46 |
# File 'lib/zlocalize/source_parser.rb', line 44 def to_entry_string @text.force_encoding("UTF-8") end |
#to_translation_entry(filename) ⇒ Object
Since Expression is an abstract class, no output is generated (descendants redefine this method)
40 41 42 |
# File 'lib/zlocalize/source_parser.rb', line 40 def to_translation_entry(filename) nil end |