Class: ZLocalize::Expression

Inherits:
Object
  • Object
show all
Defined in:
lib/zlocalize/rdoc_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.



22
23
24
# File 'lib/zlocalize/rdoc_source_parser.rb', line 22

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.



18
19
20
# File 'lib/zlocalize/rdoc_source_parser.rb', line 18

def char_no
  @char_no
end

#line_noObject

:nodoc: all



17
18
19
# File 'lib/zlocalize/rdoc_source_parser.rb', line 17

def line_no
  @line_no
end

#sub_methodObject

Returns the value of attribute sub_method.



20
21
22
# File 'lib/zlocalize/rdoc_source_parser.rb', line 20

def sub_method
  @sub_method
end

#textObject

Returns the value of attribute text.



19
20
21
# File 'lib/zlocalize/rdoc_source_parser.rb', line 19

def text
  @text
end

Instance Method Details

#display(indent = 0) ⇒ Object

display this Expression as a string. Used for debugging purposes



37
38
39
40
# File 'lib/zlocalize/rdoc_source_parser.rb', line 37

def display(indent = 0)
  i = prefix(indent)
  i << "#{self.class.name} (#{line_no},#{char_no}): #{@text}\n"
end

#is_translate_callObject



52
53
54
# File 'lib/zlocalize/rdoc_source_parser.rb', line 52

def is_translate_call
  false
end

#prefix(indent) ⇒ Object

puts spaces before the output generated by display. Used for debugging purposes.



32
33
34
# File 'lib/zlocalize/rdoc_source_parser.rb', line 32

def prefix(indent)
  ' ' * (indent*INDENT_STEP)
end

#set_text(t) ⇒ Object



26
27
28
29
# File 'lib/zlocalize/rdoc_source_parser.rb', line 26

def set_text(t)
  @text = t
  self
end

#to_entry_stringObject



48
49
50
# File 'lib/zlocalize/rdoc_source_parser.rb', line 48

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)



44
45
46
# File 'lib/zlocalize/rdoc_source_parser.rb', line 44

def to_translation_entry(filename)
  nil
end