Class: Types::Class
- Inherits:
-
Object
- Object
- Types::Class
- Extended by:
- Generic
- Includes:
- Generic
- Defined in:
- lib/types/class.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Class Method Summary collapse
Instance Method Summary collapse
- #composite? ⇒ Boolean
-
#initialize(base) ⇒ Class
constructor
A new instance of Class.
- #parse(input) ⇒ Object
Methods included from Generic
Constructor Details
#initialize(base) ⇒ Class
Returns a new instance of Class.
30 31 32 |
# File 'lib/types/class.rb', line 30 def initialize(base) @base = base end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
34 35 36 |
# File 'lib/types/class.rb', line 34 def base @base end |
Class Method Details
.parse(input) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/types/class.rb', line 54 def self.parse(input) klass = Object.const_get(input) if !klass.is_a?(::Class) raise ArgumentError, "Class #{klass} is not a Class!" end return klass end |
Instance Method Details
#parse(input) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/types/class.rb', line 40 def parse(input) klass = Object.const_get(input) if @base and !klass.ancestors.include?(@base) raise ArgumentError, "Class #{klass} is not a subclass of #{@base}!" end return klass end |