Class: Stupidedi::Reader::CompositeElementTok
- Includes:
- Inspect
- Defined in:
- lib/stupidedi/reader/tokens/composite_element_tok.rb
Instance Attribute Summary collapse
- #component_toks ⇒ Array<ComponentElementTok> readonly
- #position ⇒ Position readonly
- #remainder ⇒ Position readonly
Constructors collapse
Instance Method Summary collapse
- #blank? ⇒ Boolean
- #composite? ⇒ Boolean
- #copy(changes = {}) ⇒ CompositeElementTok
-
#initialize(component_toks, position, remainder) ⇒ CompositeElementTok
constructor
A new instance of CompositeElementTok.
- #present? ⇒ Boolean
- #pretty_print(q) ⇒ Object
- #repeated ⇒ Object
- #repeated? ⇒ Boolean
- #simple? ⇒ Boolean
- #to_s(separators) ⇒ Object
Methods included from Inspect
Constructor Details
#initialize(component_toks, position, remainder) ⇒ CompositeElementTok
Returns a new instance of CompositeElementTok.
19 20 21 22 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 19 def initialize(component_toks, position, remainder) @component_toks, @position, @remainder = component_toks, position, remainder end |
Instance Attribute Details
#component_toks ⇒ Array<ComponentElementTok> (readonly)
11 12 13 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 11 def component_toks @component_toks end |
#position ⇒ Position (readonly)
14 15 16 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 14 def position @position end |
#remainder ⇒ Position (readonly)
17 18 19 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 17 def remainder @remainder end |
Class Method Details
.build(component_toks, position, remainder) ⇒ CompositeElementTok
75 76 77 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 75 def build(component_toks, position, remainder) new(component_toks, position, remainder) end |
Instance Method Details
#blank? ⇒ Boolean
44 45 46 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 44 def blank? @component_toks.all?(&:blank?) end |
#composite? ⇒ Boolean
56 57 58 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 56 def composite? true end |
#copy(changes = {}) ⇒ CompositeElementTok
25 26 27 28 29 30 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 25 def copy(changes = {}) CompositeElementTok.new \ changes.fetch(:component_toks, @component_toks), changes.fetch(:position, @position), changes.fetch(:remainder, @remainder) end |
#present? ⇒ Boolean
48 49 50 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 48 def present? not blank? end |
#pretty_print(q) ⇒ Object
32 33 34 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 32 def pretty_print(q) q.pp(:composite.cons(@component_toks)) end |
#repeated ⇒ Object
36 37 38 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 36 def repeated RepeatedElementTok.new(self.cons, @position) end |
#repeated? ⇒ Boolean
40 41 42 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 40 def repeated? false end |
#simple? ⇒ Boolean
52 53 54 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 52 def simple? false end |
#to_s(separators) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/stupidedi/reader/tokens/composite_element_tok.rb', line 60 def to_s(separators) if blank? "" else cs = @component_toks.map{|x| x.to_s(separators) } cs.join(separators.component) end end |