Class: Cosensee::ParsedBracket
- Inherits:
-
Object
- Object
- Cosensee::ParsedBracket
- Defined in:
- lib/cosensee/parsed_bracket.rb
Overview
parse a line
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #first_content ⇒ Object
-
#initialize(content: []) ⇒ ParsedBracket
constructor
A new instance of ParsedBracket.
- #parsed? ⇒ Boolean
- #single_text? ⇒ Boolean
- #update(**attributes) ⇒ Object
Constructor Details
#initialize(content: []) ⇒ ParsedBracket
Returns a new instance of ParsedBracket.
6 7 8 9 |
# File 'lib/cosensee/parsed_bracket.rb', line 6 def initialize(content: []) @content = content @parsed = false end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
11 12 13 |
# File 'lib/cosensee/parsed_bracket.rb', line 11 def content @content end |
Instance Method Details
#==(other) ⇒ Object
36 37 38 39 40 |
# File 'lib/cosensee/parsed_bracket.rb', line 36 def ==(other) other.is_a?(Cosensee::ParsedBracket) && other.content == content && other.parsed? == parsed? end |
#first_content ⇒ Object
32 33 34 |
# File 'lib/cosensee/parsed_bracket.rb', line 32 def first_content content.first end |
#parsed? ⇒ Boolean
13 14 15 |
# File 'lib/cosensee/parsed_bracket.rb', line 13 def parsed? @parsed end |
#single_text? ⇒ Boolean
28 29 30 |
# File 'lib/cosensee/parsed_bracket.rb', line 28 def single_text? content.size == 1 && content.first.is_a?(String) end |
#update(**attributes) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cosensee/parsed_bracket.rb', line 17 def update(**attributes) attributes.each do |key, value| # Check if the key is a valid accessor raise ArgumentError, "Attribute #{key} is not allowed to be updated." unless self.class.method_defined?("#{key}=") public_send("#{key}=", value) end self end |