Class: Fit::ParseHolder
- Inherits:
-
Object
- Object
- Fit::ParseHolder
- Defined in:
- lib/fit/parse.rb
Overview
This ParseHolder class is necessary to cope with the different constructors in the Java version of FIT. One of them is the constructor for the Parse Ruby class, the other is a static method in the ParseHolder class.
ParseHolder also maintain all the methods belonging to Parse which are instead called whenever in FIT a ParseHolder is created instead of a Parse.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#end ⇒ Object
Returns the value of attribute end.
-
#leader ⇒ Object
Returns the value of attribute leader.
-
#more ⇒ Object
Returns the value of attribute more.
-
#parts ⇒ Object
Returns the value of attribute parts.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#trailer ⇒ Object
Returns the value of attribute trailer.
Class Method Summary collapse
Instance Method Summary collapse
- #add_to_body(text) ⇒ Object
- #add_to_tag(text) ⇒ Object
- #at(i, *rest) ⇒ Object
- #last ⇒ Object
- #leaf ⇒ Object
- #print(out, conv = nil) ⇒ Object
- #size ⇒ Object
- #text ⇒ Object
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
24 25 26 |
# File 'lib/fit/parse.rb', line 24 def body @body end |
#end ⇒ Object
Returns the value of attribute end.
24 25 26 |
# File 'lib/fit/parse.rb', line 24 def end @end end |
#leader ⇒ Object
Returns the value of attribute leader.
24 25 26 |
# File 'lib/fit/parse.rb', line 24 def leader @leader end |
#more ⇒ Object
Returns the value of attribute more.
25 26 27 |
# File 'lib/fit/parse.rb', line 25 def more @more end |
#parts ⇒ Object
Returns the value of attribute parts.
25 26 27 |
# File 'lib/fit/parse.rb', line 25 def parts @parts end |
#tag ⇒ Object
Returns the value of attribute tag.
24 25 26 |
# File 'lib/fit/parse.rb', line 24 def tag @tag end |
#trailer ⇒ Object
Returns the value of attribute trailer.
24 25 26 |
# File 'lib/fit/parse.rb', line 24 def trailer @trailer end |
Class Method Details
.create(tag, body, parts, more) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fit/parse.rb', line 27 def ParseHolder.create tag, body, parts, more p = new p.leader = "\n" p.tag = "<#{tag}>" p.body = body p.end = "</#{tag}>" p.trailer = "" p.parts = parts p.more = more p end |
Instance Method Details
#add_to_body(text) ⇒ Object
47 48 49 |
# File 'lib/fit/parse.rb', line 47 def add_to_body text @body += text end |
#add_to_tag(text) ⇒ Object
43 44 45 |
# File 'lib/fit/parse.rb', line 43 def add_to_tag text @tag = @tag[0..-2] + "#{text}>" end |
#at(i, *rest) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/fit/parse.rb', line 51 def at i, *rest node = (i == 0 || @more.nil?) ? self : @more.at(i - 1) rest.each do |j| node = node.parts.at(j) end node end |
#last ⇒ Object
63 64 65 |
# File 'lib/fit/parse.rb', line 63 def last @more.nil? ? self : @more.last end |
#leaf ⇒ Object
39 40 41 |
# File 'lib/fit/parse.rb', line 39 def leaf @parts.nil? ? self : @parts.leaf end |
#print(out, conv = nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fit/parse.rb', line 71 def print out, conv=nil out.print conv.nil? ? @leader : conv.iconv(@leader) out.print conv.nil? ? @tag : conv.iconv(@tag) if @parts @parts.print out, conv else out.print conv.nil? ? @body : conv.iconv(@body) end out.print conv.nil? ? @end : conv.iconv(@end) if @more @more.print out, conv else out.print conv.nil? ? @trailer : conv.iconv(@end) end end |
#size ⇒ Object
67 68 69 |
# File 'lib/fit/parse.rb', line 67 def size @more.nil? ? 1 : @more.size + 1 end |
#text ⇒ Object
59 60 61 |
# File 'lib/fit/parse.rb', line 59 def text Parse.html_to_text @body end |