Class: Chitin::StringMethod

Inherits:
Object show all
Includes:
Runnable
Defined in:
lib/chitin/commands/ruby.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Instance Attribute Details

#chainsObject (readonly)

Returns the value of attribute chains.



5
6
7
# File 'lib/chitin/commands/ruby.rb', line 5

def chains
  @chains
end

#pidObject (readonly)

Returns the value of attribute pid.



6
7
8
# File 'lib/chitin/commands/ruby.rb', line 6

def pid
  @pid
end

Instance Method Details

#|(other) ⇒ Object



16
17
18
# File 'lib/chitin/commands/ruby.rb', line 16

def |(other)
  Pipe.new self, other
end