Class: LangScan::Type::TypeGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/langscan/_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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

#eachObject



33
34
35
# File 'lib/langscan/_type.rb', line 33

def each
  @members.each {|info| yield(info) }
end

#has_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/langscan/_type.rb', line 29

def has_type?(type)
  @by_type.include?(type)
end