Module: CUI8Tracks::Thing

Included in:
API, Mix, Set, User
Defined in:
lib/cui8tracks/thing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/cui8tracks/thing.rb', line 20

def method_missing(name, *args, &block)
  if data && data.has_key?(name.to_s)
    data[name.to_s]
  else
    super
  end
end

Instance Attribute Details

#sessionObject

Returns the value of attribute session.



2
3
4
# File 'lib/cui8tracks/thing.rb', line 2

def session
  @session
end

Instance Method Details

#apiObject



12
13
14
# File 'lib/cui8tracks/thing.rb', line 12

def api
  session.api
end

#dataObject



28
29
30
# File 'lib/cui8tracks/thing.rb', line 28

def data
  @data
end

#idObject



38
39
40
# File 'lib/cui8tracks/thing.rb', line 38

def id
  @data['id']
end

#info(data = self.data) ⇒ Object



32
33
34
35
36
# File 'lib/cui8tracks/thing.rb', line 32

def info(data = self.data)
  data.each_key{ |key|
    logger.info "#{self.class.to_s}::#{key} = #{data[key]}"
  }
end

#initialize(data = nil) ⇒ Object



4
5
6
# File 'lib/cui8tracks/thing.rb', line 4

def initialize(data = nil)
  @data = data
end

#loggerObject



8
9
10
# File 'lib/cui8tracks/thing.rb', line 8

def logger
  session.logger
end

#notify(title, message) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/cui8tracks/thing.rb', line 49

def notify(title, message)
  Notify.notify(title, message)
  # Thread.new {
  #   @@notifier = Growl.new 'localhost', 'ruby', ['notify']
  #   @@notifier.notify 'notify', title, message
  # }
end

#path(method = '') ⇒ Object



42
43
44
45
46
47
# File 'lib/cui8tracks/thing.rb', line 42

def path(method = '')
  classname = self.class.to_s.split(/::/).last.downcase
  classname += 'e' if classname =~ /x$/
  classname += 's'
  "/#{classname}/#{self.id}/" + method
end

#setObject



16
17
18
# File 'lib/cui8tracks/thing.rb', line 16

def set
  session.set
end