Module: Typ::Is::Array
- Defined in:
- lib/typ.rb
Defined Under Namespace
Modules: Singleton
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(gate) ⇒ Object
70 71 72 |
# File 'lib/typ.rb', line 70 def self.included gate gate.extend Singleton end |
.new(array) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/typ.rb', line 52 def new array check = if array[0].is_a?(Symbol) method, *arguments = array -> receiver { receiver.send method, *arguments } elsif array[1].is_a?(Symbol) receiver, method = array -> argument { receiver.send method, argument } else fail "not sure how to handle #{array} yet" end gate = Class.new gate.include self gate.check, gate.array = check, array gate end |
Instance Method Details
#initialize(it) ⇒ Object
86 87 88 |
# File 'lib/typ.rb', line 86 def initialize it @ok = self.class.check[it] end |
#ok? ⇒ Boolean
82 83 84 |
# File 'lib/typ.rb', line 82 def ok? @ok end |
#to_a ⇒ Object
78 79 80 |
# File 'lib/typ.rb', line 78 def to_a self.class.array end |