Class: ZLocalize::Expression

Inherits:
Object
  • Object
show all
Defined in:
lib/zlocalize/source_parser.rb

Overview

base class for Expressions we’re interested in

Instance Attribute Summary collapse

Instance Method Summary collapse

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_noObject

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_noObject

:nodoc: all



13
14
15
# File 'lib/zlocalize/source_parser.rb', line 13

def line_no
  @line_no
end

#sub_methodObject

Returns the value of attribute sub_method.



16
17
18
# File 'lib/zlocalize/source_parser.rb', line 16

def sub_method
  @sub_method
end

#textObject

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_callObject



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_stringObject



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