Class: Wood::Types::Array
- Inherits:
-
CompoundType
- Object
- CompoundType
- Wood::Types::Array
- Defined in:
- lib/wood/types.rb
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Attributes inherited from CompoundType
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #===(other) ⇒ Object
- #builtin? ⇒ Boolean
-
#initialize(type, size = nil) ⇒ Array
constructor
A new instance of Array.
- #name ⇒ Object
- #node_name ⇒ Object
- #numeric? ⇒ Boolean
- #sexp ⇒ Object
Methods inherited from CompoundType
Methods included from TypeMatching
Constructor Details
#initialize(type, size = nil) ⇒ Array
Returns a new instance of Array.
58 59 60 61 |
# File 'lib/wood/types.rb', line 58 def initialize(type, size = nil) super(type) @size = size end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
57 58 59 |
# File 'lib/wood/types.rb', line 57 def size @size end |
Class Method Details
.[](*options) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/wood/types.rb', line 47 def self.[](*) case .first when Hash = .first new([:type], [:size]) else new(*) end end |
Instance Method Details
#==(other) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/wood/types.rb', line 71 def == other case other when Array if size && other.size return type == other.type && size == other.size else return type == other.type end else return false end end |
#===(other) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/wood/types.rb', line 84 def === other case other when Array if size && other.size return type === other.type && size === other.size else return type === other.type end else return false end end |
#builtin? ⇒ Boolean
101 102 103 |
# File 'lib/wood/types.rb', line 101 def builtin? type && type.builtin? end |
#name ⇒ Object
63 64 65 |
# File 'lib/wood/types.rb', line 63 def name [:array, type.name] end |
#node_name ⇒ Object
67 68 69 |
# File 'lib/wood/types.rb', line 67 def node_name :array_type end |
#numeric? ⇒ Boolean
97 98 99 |
# File 'lib/wood/types.rb', line 97 def numeric? type && type.numeric? end |
#sexp ⇒ Object
105 106 107 |
# File 'lib/wood/types.rb', line 105 def sexp [:array, type.sexp, size.sexp] end |