Class: GMail::TagList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gmail/taglist.rb

Overview

Represent a bag of tags backed by a TC db

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (TagList) initialize

Constructor



17
18
19
# File 'lib/gmail/taglist.rb', line 17

def initialize
  @list = Hash.new{0}
end

Instance Attribute Details

- (Object) list

Returns the value of attribute list



14
15
16
# File 'lib/gmail/taglist.rb', line 14

def list
  @list
end

Instance Method Details

- (Object) <<(e)

<<

Parameters:



43
44
45
46
47
48
49
50
# File 'lib/gmail/taglist.rb', line 43

def <<(e)
  if e.class == GMail::Tag
    @list[e] += 1
  else
    @list[GMail::Tag.new(e)] += 1
  end
  self
end

- (Fixnum) [](k)

Parameters:

Returns:

  • (Fixnum)

    counter



29
30
31
# File 'lib/gmail/taglist.rb', line 29

def [](k)
  @list[k]
end

- (Fixnum) []=(k, v)

[]=

Parameters:

  • k (GMail::Tag)

    tag to get the counter of

  • v (Fixnum)

    value to set the counter to

Returns:

  • (Fixnum)

    counter



37
38
39
# File 'lib/gmail/taglist.rb', line 37

def []=(k, v)
  @list[k] = v
end

- (Object) add(e)

add

Parameters:



54
55
56
# File 'lib/gmail/taglist.rb', line 54

def add(e)
  self.<<(e)
end

- (Object) each

iterator



22
23
24
# File 'lib/gmail/taglist.rb', line 22

def each
  @list.each_key{|e| yield e}
end

- (Boolean) include?(elem)

include?

Parameters:

  • elem (GMail::Tag|String)

    check if elem is present in the list

Returns:

  • (Boolean)


60
61
62
# File 'lib/gmail/taglist.rb', line 60

def include?(elem)
  @list.include?(elem)
end

- (Array) keys

keys

Returns:

  • (Array)

    list of all keys



72
73
74
# File 'lib/gmail/taglist.rb', line 72

def keys
  @list.keys
end

- (Fixnum) length

length

Returns:

  • (Fixnum)

    list length



66
67
68
# File 'lib/gmail/taglist.rb', line 66

def length
  @list.length
end