Class: Keisan::StringAndGroupParser::CommentPortion
- Defined in:
- lib/keisan/string_and_group_parser.rb
Instance Attribute Summary collapse
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Attributes inherited from Portion
Instance Method Summary collapse
-
#initialize(expression, start_index) ⇒ CommentPortion
constructor
A new instance of CommentPortion.
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(expression, start_index) ⇒ CommentPortion
Returns a new instance of CommentPortion.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/keisan/string_and_group_parser.rb', line 161 def initialize(expression, start_index) super(start_index) if expression[start_index] != '#' raise Keisan::Exceptions::TokenizingError.new("Comment should start with '#'") else index = start_index + 1 end while index < expression.size break if expression[index] == "\n" index += 1 end @end_index = index @string = expression[start_index...end_index] end |
Instance Attribute Details
#string ⇒ Object (readonly)
Returns the value of attribute string.
159 160 161 |
# File 'lib/keisan/string_and_group_parser.rb', line 159 def string @string end |
Instance Method Details
#size ⇒ Object
179 180 181 |
# File 'lib/keisan/string_and_group_parser.rb', line 179 def size string.size end |
#to_s ⇒ Object
183 184 185 |
# File 'lib/keisan/string_and_group_parser.rb', line 183 def to_s string end |