Class: Toodledo::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/toodledo/context.rb

Overview

A read only representation of a context.

Constant Summary collapse

NO_CONTEXT =
Context.new(0, "No Context")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name) ⇒ Context

Returns a new instance of Context.



8
9
10
11
# File 'lib/toodledo/context.rb', line 8

def initialize(id, name)
  @id = id
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/toodledo/context.rb', line 15

def name
  @name
end

Class Method Details

.parse(session, el) ⇒ Object

Parses the context of an REXML element.



28
29
30
31
32
33
# File 'lib/toodledo/context.rb', line 28

def self.parse(session, el)
  id = el.attributes['id']
  name = el.text
  context = Context.new(id, name)
  return context
end

Instance Method Details

#server_idObject



17
18
19
# File 'lib/toodledo/context.rb', line 17

def server_id
  return @id
end

#to_sObject



21
22
23
# File 'lib/toodledo/context.rb', line 21

def to_s()
  return "@[#{name}]"
end

#to_xmlObject



35
36
37
# File 'lib/toodledo/context.rb', line 35

def to_xml()
  return "<context id=\"#{@id}\">#{@name}</context>"
end