Class: GMail::Tag
- Inherits:
-
Object
- Object
- GMail::Tag
- Includes:
- Comparable
- Defined in:
- lib/gmail/tag.rb
Overview
Handles GMail tags
Used when creating a mailbox based on the tag itself, after replacing the “/” used by GMail by “-”
Instance Attribute Summary (collapse)
-
- (Object) label
readonly
label tag's name.
Instance Method Summary (collapse)
-
- (Object) <=>(e)
comparison.
-
- (Tag) initialize(label)
constructor
Create a new tag from the parameter.
-
- (True|False) match(tags)
Match the tag against another one or multiple values If @label is “Bar” then.
-
- (String) to_s
Generate a FS-compatible label If @label is “Foo/Bar”.
Constructor Details
- (Tag) initialize(label)
Create a new tag from the parameter
Tag.new("the/tag") # => a new tag
20 21 22 23 |
# File 'lib/gmail/tag.rb', line 20 def initialize(label) @label = label raise ArgumentError if label.nil? end |
Instance Attribute Details
- (Object) label (readonly)
label tag's name
16 17 18 |
# File 'lib/gmail/tag.rb', line 16 def label @label end |
Instance Method Details
- (Object) <=>(e)
comparison
54 55 56 |
# File 'lib/gmail/tag.rb', line 54 def <=>(e) @label <=> e.label end |
- (True|False) match(tags)
Match the tag against another one or multiple values If @label is “Bar” then
self.match("Bar") # => true self.match(["Foo", "Bar"]) # => true self.match(["tag1", "tag2"]) # => false
42 43 44 45 46 47 48 49 50 |
# File 'lib/gmail/tag.rb', line 42 def match() t = .dup if .class == String t = [ ] end flag = false t.each{|e| flag = @label == e ? true : false } flag end |
- (String) to_s
Generate a FS-compatible label If @label is “Foo/Bar”
self.to_s # => "Foo-Bar"
30 31 32 |
# File 'lib/gmail/tag.rb', line 30 def to_s @label.gsub(%r{/}, '-') end |