Class: CheckIn::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/check_in/reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ Reader

Returns a new instance of Reader.



4
5
6
# File 'lib/check_in/reader.rb', line 4

def initialize(base)
  @base = base
end

Instance Attribute Details

#baseObject (readonly)

Returns the value of attribute base.



3
4
5
# File 'lib/check_in/reader.rb', line 3

def base
  @base
end

Instance Method Details

#check_in_configurationObject



22
23
24
# File 'lib/check_in/reader.rb', line 22

def check_in_configuration
  base.check_in_configuration
end

#checkinsObject



12
13
14
15
16
17
18
19
20
# File 'lib/check_in/reader.rb', line 12

def checkins
  raw_checkins.collect do |c|
    value, time = c.split(" | ")
    {
      :value => value,
      :time => Time.parse(time)
    }
  end.sort{ |a, b| a[:time] <=> b[:time] }
end

#raw_checkinsObject



8
9
10
# File 'lib/check_in/reader.rb', line 8

def raw_checkins
  CheckIn.redis.lrange(check_in_configuration.redis_key, 0, check_in_configuration.list_length)
end