Class: Tkellem::Backlog::Device

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*a) ⇒ Device

Returns a new instance of Device.



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

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

Instance Attribute Details

#countryObject

Returns the value of attribute country

Returns:

  • (Object)

    the current value of country



65
66
67
# File 'lib/tkellem/plugins/backlog.rb', line 65

def country
  @country
end

#device_nameObject

Returns the value of attribute device_name

Returns:

  • (Object)

    the current value of device_name



65
66
67
# File 'lib/tkellem/plugins/backlog.rb', line 65

def device_name
  @device_name
end

#network_userObject

Returns the value of attribute network_user

Returns:

  • (Object)

    the current value of network_user



65
66
67
# File 'lib/tkellem/plugins/backlog.rb', line 65

def network_user
  @network_user
end

#positionsObject

Returns the value of attribute positions

Returns:

  • (Object)

    the current value of positions



65
66
67
# File 'lib/tkellem/plugins/backlog.rb', line 65

def positions
  @positions
end

#time_zoneObject

Returns the value of attribute time_zone

Returns:

  • (Object)

    the current value of time_zone



65
66
67
# File 'lib/tkellem/plugins/backlog.rb', line 65

def time_zone
  @time_zone
end

Instance Method Details

#pos(ctx_name, pos_for_new = 0) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/tkellem/plugins/backlog.rb', line 77

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



71
72
73
74
75
# File 'lib/tkellem/plugins/backlog.rb', line 71

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