Class: Benelux::Mark

Inherits:
Time
  • Object
show all
Includes:
TagHelpers
Defined in:
lib/benelux/mark.rb

Instance Attribute Summary collapse

Attributes included from TagHelpers

#tags

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TagHelpers

normalize, #tag_values

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/benelux/mark.rb', line 4

def name
  @name
end

Class Method Details

.now(n = nil) ⇒ Object



5
6
7
8
9
10
# File 'lib/benelux/mark.rb', line 5

def self.now(n=nil)
  v = super()
  v.tags = Benelux::Tags.new
  v.name = n 
  v
end

Instance Method Details

#==(other) ⇒ Object



33
34
35
36
37
38
# File 'lib/benelux/mark.rb', line 33

def ==(other)
  return false unless other.respond_to? :call_id
  self.name == other.name &&
  self.tags == other.tags &&
  self.to_f == self.to_f
end

#add_tags(tags = Benelux::Tags.new) ⇒ Object Also known as: add_tag



14
15
16
# File 'lib/benelux/mark.rb', line 14

def add_tags(tags=Benelux::Tags.new)
  @tags.merge! tags
end

#distance(time) ⇒ Object



30
31
32
# File 'lib/benelux/mark.rb', line 30

def distance(time)
  self - time
end

#inspect(reftime = nil) ⇒ Object



22
23
24
25
# File 'lib/benelux/mark.rb', line 22

def inspect(reftime=nil)
  val = reftime.nil? ? self : (reftime - self)
  "#<%s:%s at=%f name=%s %s>" % [self.class, hexoid, to_f, name, tags]
end

#remove_tags(*tags) ⇒ Object Also known as: remove_tag



18
19
20
# File 'lib/benelux/mark.rb', line 18

def remove_tags(*tags)
  @tags.delete_if { |n,v| tags.member?(n) }
end

#to_s(reftime = nil) ⇒ Object



26
27
28
29
# File 'lib/benelux/mark.rb', line 26

def to_s(reftime=nil)
  val = reftime.nil? ? self : (reftime - self)
  val.to_f.to_s
end

#trackObject



11
12
13
# File 'lib/benelux/mark.rb', line 11

def track 
  @tags[:track]
end