Class: Ruby::String
- Inherits:
-
DelimitedList
- Object
- Node
- Aggregate
- List
- DelimitedList
- Ruby::String
- Defined in:
- lib/ruby/string.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes included from Node::Composite
Instance Method Summary collapse
- #dynamic? ⇒ Boolean
-
#initialize(contents = nil, ldelim = nil, rdelim = nil) ⇒ String
constructor
A new instance of String.
- #respond_to?(method) ⇒ Boolean
- #value ⇒ Object
Methods inherited from DelimitedList
Methods inherited from List
Methods included from Alternation::List
Methods included from Conversions::List
Methods inherited from Aggregate
#position, #position=, #prolog, #prolog=, #to_ruby
Methods inherited from Node
#<=>, #all_nodes, #column, #length, #nodes, #row
Methods included from Conversions
Methods included from Node::Traversal
#has_token?, #has_type?, #has_value?, #is_instance_of?, #left_of?, #matches?, #position?, #right_of?, #select
Methods included from Node::Source
#context, #filename, #line, #lines, #src
Methods included from Node::Composite
Constructor Details
#initialize(contents = nil, ldelim = nil, rdelim = nil) ⇒ String
Returns a new instance of String.
8 9 10 |
# File 'lib/ruby/string.rb', line 8 def initialize(contents = nil, ldelim = nil, rdelim = nil) super(contents, ldelim, rdelim) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ruby::List
Instance Method Details
#dynamic? ⇒ Boolean
16 17 18 |
# File 'lib/ruby/string.rb', line 16 def dynamic? !elements.inject(true) { |result, element| result && element.respond_to?(:value) } end |
#respond_to?(method) ⇒ Boolean
20 21 22 23 |
# File 'lib/ruby/string.rb', line 20 def respond_to?(method) return false if method.to_sym == :value && dynamic? super end |
#value ⇒ Object
12 13 14 |
# File 'lib/ruby/string.rb', line 12 def value map { |content| content.value }.join end |