Class: Chitin::StringMethod
- Includes:
- Runnable
- Defined in:
- lib/chitin/commands/ruby.rb
Instance Attribute Summary collapse
-
#chains ⇒ Object
readonly
Returns the value of attribute chains.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
-
#initialize(*arr, &block) ⇒ StringMethod
constructor
A new instance of StringMethod.
- #method_missing(*arr, &block) ⇒ Object
- #|(other) ⇒ Object
Methods included from Runnable
Constructor Details
#initialize(*arr, &block) ⇒ StringMethod
Returns a new instance of StringMethod.
8 9 10 11 12 13 14 |
# File 'lib/chitin/commands/ruby.rb', line 8 def initialize(*arr, &block) raise "Need at least a method name" unless [String, Symbol].include? arr.first.class @chains = [] latest = [*arr] latest << block if block @chains << latest end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*arr, &block) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/chitin/commands/ruby.rb', line 20 def method_missing(*arr, &block) latest = [*arr] latest << block if block @chains << latest self # chainable end |