Class: Yome::Chip
- Inherits:
-
Object
- Object
- Yome::Chip
- Defined in:
- lib/yome/chip.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#end_index ⇒ Object
readonly
Returns the value of attribute end_index.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
- #has_src? ⇒ Boolean
-
#initialize(line, path, index) ⇒ Chip
constructor
A new instance of Chip.
- #parse(parser) ⇒ Object
Constructor Details
#initialize(line, path, index) ⇒ Chip
Returns a new instance of Chip.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/yome/chip.rb', line 10 def initialize(line, path, index) @kind, @content = line.scan(/YOME:([\w.,]*) *(.*)/)[0] @path = path @index = index if @kind == "" @kind = "text" else # section? begin @priority = Float(@kind) @kind = "section" rescue ArgumentError end end end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/yome/chip.rb', line 4 def content @content end |
#end_index ⇒ Object (readonly)
Returns the value of attribute end_index.
8 9 10 |
# File 'lib/yome/chip.rb', line 8 def end_index @end_index end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
7 8 9 |
# File 'lib/yome/chip.rb', line 7 def index @index end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
3 4 5 |
# File 'lib/yome/chip.rb', line 3 def kind @kind end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/yome/chip.rb', line 6 def path @path end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
5 6 7 |
# File 'lib/yome/chip.rb', line 5 def priority @priority end |
Instance Method Details
#has_src? ⇒ Boolean
50 51 52 |
# File 'lib/yome/chip.rb', line 50 def has_src? index < end_index end |
#parse(parser) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/yome/chip.rb', line 27 def parse(parser) file = parser.file_hash[path] i = index + 1 while i < file.length do if file[i] =~ /YOME:([\w.,]*) *(.*)/ truncate_using_end = true if $1 == "end" break end i += 1 end @end_index = i - 1 unless truncate_using_end @end_index = [end_index, index + 8].min end while file[end_index] =~ /^\s*$/ @end_index -= 1 end end |