Class: Contraction::TypedContainer
- Inherits:
-
Object
- Object
- Contraction::TypedContainer
- Defined in:
- lib/parser/type_parser.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#type_list ⇒ Object
readonly
Returns the value of attribute type_list.
Instance Method Summary collapse
- #check(thing) ⇒ Object
-
#initialize(class_type, type_list) ⇒ TypedContainer
constructor
A new instance of TypedContainer.
- #works_as_a?(thing) ⇒ Boolean
Constructor Details
#initialize(class_type, type_list) ⇒ TypedContainer
Returns a new instance of TypedContainer.
108 109 110 111 |
# File 'lib/parser/type_parser.rb', line 108 def initialize(class_type, type_list) @type_list = type_list @class_name = class_type end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
106 107 108 |
# File 'lib/parser/type_parser.rb', line 106 def class_name @class_name end |
#type_list ⇒ Object (readonly)
Returns the value of attribute type_list.
106 107 108 |
# File 'lib/parser/type_parser.rb', line 106 def type_list @type_list end |
Instance Method Details
#check(thing) ⇒ Object
117 118 119 120 |
# File 'lib/parser/type_parser.rb', line 117 def check(thing) return false if !class_name.nil? && !class_name.check(thing) thing.all? { |v| type_list.works_as_a? v } end |
#works_as_a?(thing) ⇒ Boolean
113 114 115 |
# File 'lib/parser/type_parser.rb', line 113 def works_as_a?(thing) type_list.works_as_a? thing end |