Class: DMatch::Obj
- Includes:
- Predicated
- Defined in:
- lib/destructure/types.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(fields = {}, &pred) ⇒ Obj
constructor
A new instance of Obj.
Methods included from Predicated
Constructor Details
#initialize(fields = {}, &pred) ⇒ Obj
Returns a new instance of Obj.
59 60 61 62 |
# File 'lib/destructure/types.rb', line 59 def initialize(fields={}, &pred) @fields = fields self.pred = pred end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
57 58 59 |
# File 'lib/destructure/types.rb', line 57 def fields @fields end |
Class Method Details
.of_type(klass, fields = {}, &pred) ⇒ Object
64 65 66 |
# File 'lib/destructure/types.rb', line 64 def self.of_type(klass, fields={}, &pred) Obj.new(fields) {|x| x.is_a?(klass) && (!pred || pred.call(x))} end |