Class: Trendhub::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/trendhub/repository.rb

Constant Summary collapse

TIME_ALIASES =
{
  "daily" => "today",
  "weekly" => "this week",
  "monthly" => "this month",
}

Instance Attribute Summary collapse

Instance Method Summary collapse

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_starsObject (readonly)

Returns the value of attribute added_stars.



10
11
12
# File 'lib/trendhub/repository.rb', line 10

def added_stars
  @added_stars
end

#descObject (readonly)

Returns the value of attribute desc.



8
9
10
# File 'lib/trendhub/repository.rb', line 8

def desc
  @desc
end

#forksObject (readonly)

Returns the value of attribute forks.



12
13
14
# File 'lib/trendhub/repository.rb', line 12

def forks
  @forks
end

#languageObject (readonly)

Returns the value of attribute language.



9
10
11
# File 'lib/trendhub/repository.rb', line 9

def language
  @language
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/trendhub/repository.rb', line 5

def name
  @name
end

#starsObject (readonly)

Returns the value of attribute stars.



11
12
13
# File 'lib/trendhub/repository.rb', line 11

def stars
  @stars
end

#time_rangeObject (readonly)

Returns the value of attribute time_range.



6
7
8
# File 'lib/trendhub/repository.rb', line 6

def time_range
  @time_range
end

#urlObject (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_periodObject



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