Class: HackernewsApi::PollOpt

Inherits:
Object
  • Object
show all
Defined in:
lib/hackernews_api/poll_opt.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ PollOpt

Returns a new instance of PollOpt.



10
11
12
13
14
15
16
17
# File 'lib/hackernews_api/poll_opt.rb', line 10

def initialize json
  @id     = json['id']
  @by     = json['by']
  @time   = DateTime.strptime(json['time'].to_s, '%s')
  @type   = json['type']
  @parent = json['parent']
  @text = json['text']
end

Instance Attribute Details

#byObject (readonly)

Returns the value of attribute by.



8
9
10
# File 'lib/hackernews_api/poll_opt.rb', line 8

def by
  @by
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/hackernews_api/poll_opt.rb', line 8

def id
  @id
end

#parentObject (readonly)

Returns the value of attribute parent.



8
9
10
# File 'lib/hackernews_api/poll_opt.rb', line 8

def parent
  @parent
end

#scoreObject (readonly)

Returns the value of attribute score.



8
9
10
# File 'lib/hackernews_api/poll_opt.rb', line 8

def score
  @score
end

#textObject (readonly)

Returns the value of attribute text.



8
9
10
# File 'lib/hackernews_api/poll_opt.rb', line 8

def text
  @text
end

#timeObject (readonly)

Returns the value of attribute time.



8
9
10
# File 'lib/hackernews_api/poll_opt.rb', line 8

def time
  @time
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/hackernews_api/poll_opt.rb', line 8

def type
  @type
end

Class Method Details

.fetch(id) ⇒ Object



3
4
5
6
# File 'lib/hackernews_api/poll_opt.rb', line 3

def self.fetch id
  json = Client.fetch(:item, id)
  new(json)
end