Class: LangScan::Type::TypeGroup
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<<(info) ⇒ Object
- #[](i) ⇒ Object
- #each ⇒ Object
- #has_type?(type) ⇒ Boolean
-
#initialize(name) ⇒ TypeGroup
constructor
A new instance of TypeGroup.
Constructor Details
#initialize(name) ⇒ TypeGroup
Returns a new instance of TypeGroup.
17 18 19 20 21 |
# File 'lib/langscan/_type.rb', line 17 def initialize(name) @name = name @members = [] @by_type = {} end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/langscan/_type.rb', line 22 def name @name end |
Instance Method Details
#<<(info) ⇒ Object
24 25 26 27 |
# File 'lib/langscan/_type.rb', line 24 def << (info) @members.push(info) @by_type[info.type] = info end |
#[](i) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/langscan/_type.rb', line 37 def [] (i) if i.is_a?(Integer) @members[i] else @by_type[i] end end |
#each ⇒ Object
33 34 35 |
# File 'lib/langscan/_type.rb', line 33 def each @members.each {|info| yield(info) } end |
#has_type?(type) ⇒ Boolean
29 30 31 |
# File 'lib/langscan/_type.rb', line 29 def has_type?(type) @by_type.include?(type) end |