Class: Topsy::Page

Inherits:
Hashie::Dash
  • Object
show all
Defined in:
lib/topsy/page.rb

Constant Summary collapse

@@windows =
{'a' => :all, 'auto' => :auto, 'w' => :week, 'd' => :day, 'm' => :month, 'h' => :hour}

Instance Method Summary collapse

Constructor Details

#initialize(content, klass) ⇒ Page

Returns a new instance of Page.



33
34
35
36
# File 'lib/topsy/page.rb', line 33

def initialize(content, klass)
  @klass = klass
  super(content)
end

Instance Method Details

#[]=(property, value) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/topsy/page.rb', line 38

def []=(property, value)
  case property
    when 'list' then
      result = []
      if value
        value.each{ |x| result << @klass.new(x) }
        self[:list] = result  
      else
        self[:list] = value
      end
    when 'window' then
      if value
        self[:window] = @@windows[value]  
      end
    else
      super(property.to_s, value)
  end
end

#to_sObject



29
30
31
# File 'lib/topsy/page.rb', line 29

def to_s
  "Topsy Page: #{page} of #{total}, #{list.size} authors"
end