Class: Tkellem::Backlog::Device

Inherits:
Struct
  • Object
show all
Defined in:
lib/tkellem/plugins/backlog.rb

Overview

IMPL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*a) ⇒ Device

Returns a new instance of Device.



51
52
53
54
# File 'lib/tkellem/plugins/backlog.rb', line 51

def initialize(*a)
  super
  self.positions = {}
end

Instance Attribute Details

#device_nameObject

Returns the value of attribute device_name

Returns:

  • (Object)

    the current value of device_name



50
51
52
# File 'lib/tkellem/plugins/backlog.rb', line 50

def device_name
  @device_name
end

#network_userObject

Returns the value of attribute network_user

Returns:

  • (Object)

    the current value of network_user



50
51
52
# File 'lib/tkellem/plugins/backlog.rb', line 50

def network_user
  @network_user
end

#positionsObject

Returns the value of attribute positions

Returns:

  • (Object)

    the current value of positions



50
51
52
# File 'lib/tkellem/plugins/backlog.rb', line 50

def positions
  @positions
end

Instance Method Details

#pos(ctx_name, pos_for_new = 0) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/tkellem/plugins/backlog.rb', line 62

def pos(ctx_name, pos_for_new = 0)
  backlog_pos = self.position(ctx_name).first_or_initialize
  if backlog_pos.new_record?
    backlog_pos.position = pos_for_new
    backlog_pos.save
  end
  backlog_pos.position
end

#update_pos(ctx_name, pos) ⇒ Object



56
57
58
59
60
# File 'lib/tkellem/plugins/backlog.rb', line 56

def update_pos(ctx_name, pos)
  # TODO: it'd be a good idea to throttle these updates to once every few seconds per ctx
  # right now we're kind of harsh on the sqlite db
  self.position(ctx_name).first_or_create.update_attribute(:position, pos)
end