Class: Bake::Types::Any
- Inherits:
-
Object
- Object
- Bake::Types::Any
- Defined in:
- lib/bake/types/any.rb
Class Method Summary collapse
Instance Method Summary collapse
- #composite? ⇒ Boolean
-
#initialize(types) ⇒ Any
constructor
A new instance of Any.
- #parse(input) ⇒ Object
- #to_s ⇒ Object
- #|(other) ⇒ Object
Constructor Details
#initialize(types) ⇒ Any
Returns a new instance of Any.
30 31 32 |
# File 'lib/bake/types/any.rb', line 30 def initialize(types) @types = types end |
Class Method Details
.parse(value) ⇒ Object
50 51 52 |
# File 'lib/bake/types/any.rb', line 50 def self.parse(value) value end |
Instance Method Details
#composite? ⇒ Boolean
38 39 40 |
# File 'lib/bake/types/any.rb', line 38 def composite? @types.any?{|type| type.composite?} end |
#parse(input) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/bake/types/any.rb', line 42 def parse(input) @types.each do |type| return type.parse(input) rescue # Ignore end end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/bake/types/any.rb', line 54 def to_s "any of #{@types.join(', ')}" end |
#|(other) ⇒ Object
34 35 36 |
# File 'lib/bake/types/any.rb', line 34 def | other self.class.new([*@types, other]) end |