Class: Rapid::Template::Node::CommentNode
- Defined in:
- lib/rapid/template/node/comment_node.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#variable ⇒ Object
readonly
Returns the value of attribute variable.
Attributes inherited from Base
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(value, variable) ⇒ CommentNode
constructor
A new instance of CommentNode.
- #inspect ⇒ Object
- #pull(result) ⇒ Object
Methods inherited from Base
#content, #next_node, #next_to, #static?
Constructor Details
#initialize(value, variable) ⇒ CommentNode
Returns a new instance of CommentNode.
9 10 11 12 13 14 15 16 |
# File 'lib/rapid/template/node/comment_node.rb', line 9 def initialize value, variable @value = value @variable = variable if @variable.ends_with? "?" @variable = @variable[0..-2] end end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/rapid/template/node/comment_node.rb', line 7 def value @value end |
#variable ⇒ Object (readonly)
Returns the value of attribute variable.
7 8 9 |
# File 'lib/rapid/template/node/comment_node.rb', line 7 def variable @variable end |
Instance Method Details
#==(obj) ⇒ Object
28 29 30 31 32 |
# File 'lib/rapid/template/node/comment_node.rb', line 28 def == obj obj.is_a?(self.class) && obj.variable == variable && obj.value == value end |
#inspect ⇒ Object
34 35 36 |
# File 'lib/rapid/template/node/comment_node.rb', line 34 def inspect %(#<comment @value=#{@value.inspect} @variable=#{@variable.inspect}>) end |
#pull(result) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/rapid/template/node/comment_node.rb', line 18 def pull result len = result.starts_with "# " if len result.move! len result[variable] = value else result[variable] = !value end end |