Class: Hacker::News::User
- Inherits:
-
Struct
- Object
- Struct
- Hacker::News::User
- Defined in:
- lib/hacker/news/items.rb
Overview
A HN user profile.
Instance Attribute Summary collapse
-
#about ⇒ Object
Returns the value of attribute about.
-
#created ⇒ Object
Returns the value of attribute created.
-
#id ⇒ String
readonly
Case-sensitive username.
-
#karma ⇒ Object
Returns the value of attribute karma.
-
#submitted ⇒ Object
Returns the value of attribute submitted.
Class Method Summary collapse
Instance Attribute Details
#about ⇒ Object
Returns the value of attribute about
125 126 127 |
# File 'lib/hacker/news/items.rb', line 125 def about @about end |
#created ⇒ Object
Returns the value of attribute created
125 126 127 |
# File 'lib/hacker/news/items.rb', line 125 def created @created end |
#id ⇒ String (readonly)
Returns case-sensitive username.
125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/hacker/news/items.rb', line 125 User = Struct.new(:id, :created, :karma, :about, :submitted, keyword_init: true) do # @param h [Hash] # @return [User] def self.from_hash(h) new( id: h['id'], created: h['created'], karma: h['karma'], about: h['about'], submitted: h['submitted'] || [] ) end end |
#karma ⇒ Object
Returns the value of attribute karma
125 126 127 |
# File 'lib/hacker/news/items.rb', line 125 def karma @karma end |
#submitted ⇒ Object
Returns the value of attribute submitted
125 126 127 |
# File 'lib/hacker/news/items.rb', line 125 def submitted @submitted end |
Class Method Details
.from_hash(h) ⇒ User
128 129 130 131 132 133 134 135 136 |
# File 'lib/hacker/news/items.rb', line 128 def self.from_hash(h) new( id: h['id'], created: h['created'], karma: h['karma'], about: h['about'], submitted: h['submitted'] || [] ) end |