Class: Trendhub::Repository
- Inherits:
-
Object
- Object
- Trendhub::Repository
- Defined in:
- lib/trendhub/repository.rb
Constant Summary collapse
- TIME_ALIASES =
{ "daily" => "today", "weekly" => "this week", "monthly" => "this month", }
Instance Attribute Summary collapse
-
#added_stars ⇒ Object
readonly
Returns the value of attribute added_stars.
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#forks ⇒ Object
readonly
Returns the value of attribute forks.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#stars ⇒ Object
readonly
Returns the value of attribute stars.
-
#time_range ⇒ Object
readonly
Returns the value of attribute time_range.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(data) ⇒ Repository
constructor
A new instance of Repository.
- #time_period ⇒ Object
Constructor Details
#initialize(data) ⇒ Repository
Returns a new instance of Repository.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/trendhub/repository.rb', line 20 def initialize(data) @name = data.fetch(:name) @time_range = data.fetch(:time_range) @url = data.fetch(:url) @desc = data.fetch(:desc) @language = data.fetch(:language) @added_stars = data.fetch(:added_stars) @stars = data.fetch(:stars) @forks = data.fetch(:forks) end |
Instance Attribute Details
#added_stars ⇒ Object (readonly)
Returns the value of attribute added_stars.
10 11 12 |
# File 'lib/trendhub/repository.rb', line 10 def added_stars @added_stars end |
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
8 9 10 |
# File 'lib/trendhub/repository.rb', line 8 def desc @desc end |
#forks ⇒ Object (readonly)
Returns the value of attribute forks.
12 13 14 |
# File 'lib/trendhub/repository.rb', line 12 def forks @forks end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
9 10 11 |
# File 'lib/trendhub/repository.rb', line 9 def language @language end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/trendhub/repository.rb', line 5 def name @name end |
#stars ⇒ Object (readonly)
Returns the value of attribute stars.
11 12 13 |
# File 'lib/trendhub/repository.rb', line 11 def stars @stars end |
#time_range ⇒ Object (readonly)
Returns the value of attribute time_range.
6 7 8 |
# File 'lib/trendhub/repository.rb', line 6 def time_range @time_range end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/trendhub/repository.rb', line 7 def url @url end |
Instance Method Details
#time_period ⇒ Object
31 32 33 34 |
# File 'lib/trendhub/repository.rb', line 31 def time_period return 'today' unless self.time_range TIME_ALIASES[self.time_range] end |