Class: Typedocs::TypeSpec::Or
- Inherits:
-
Typedocs::TypeSpec
- Object
- Typedocs::TypeSpec
- Typedocs::TypeSpec::Or
- Defined in:
- lib/typedocs/type_spec.rb
Instance Method Summary collapse
-
#initialize(children) ⇒ Or
constructor
A new instance of Or.
- #to_source ⇒ Object
- #valid?(obj) ⇒ Boolean
Methods inherited from Typedocs::TypeSpec
Constructor Details
#initialize(children) ⇒ Or
Returns a new instance of Or.
164 165 166 167 168 169 170 |
# File 'lib/typedocs/type_spec.rb', line 164 def initialize(children) raise ArgumentError, "Children is empty" if children.empty? children.each do|c| Typedocs.ensure_klass(c, Typedocs::TypeSpec) end @children = children end |
Instance Method Details
#to_source ⇒ Object
174 175 176 |
# File 'lib/typedocs/type_spec.rb', line 174 def to_source "#{@children.map(&:to_source).join('|')}" end |
#valid?(obj) ⇒ Boolean
171 172 173 |
# File 'lib/typedocs/type_spec.rb', line 171 def valid?(obj) @children.any?{|spec| spec.valid? obj} end |