Class: Gh::Trending::Repositories
- Inherits:
-
Object
- Object
- Gh::Trending::Repositories
- Defined in:
- lib/gh_trending/repositories.rb
Overview
Returns an array of representation of the trending repositories in github. Usage example: Gh::Trending::Repositories.new.get(language: ‘ruby’)
Instance Attribute Summary collapse
-
#repos_list ⇒ Object
readonly
Returns the value of attribute repos_list.
Instance Method Summary collapse
- #[](idx) ⇒ Object
- #get(*args) ⇒ Object
-
#initialize(parser: nil) ⇒ Repositories
constructor
A new instance of Repositories.
- #to_h ⇒ Object
Constructor Details
#initialize(parser: nil) ⇒ Repositories
Returns a new instance of Repositories.
14 15 16 17 |
# File 'lib/gh_trending/repositories.rb', line 14 def initialize(parser: nil) @parser = parser || Gh::Trending::Parsers::ReposParser.new @repos_list = [] end |
Instance Attribute Details
#repos_list ⇒ Object (readonly)
Returns the value of attribute repos_list.
12 13 14 |
# File 'lib/gh_trending/repositories.rb', line 12 def repos_list @repos_list end |
Instance Method Details
#[](idx) ⇒ Object
26 27 28 |
# File 'lib/gh_trending/repositories.rb', line 26 def [](idx) repos_list[idx] end |
#get(*args) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/gh_trending/repositories.rb', line 19 def get(*args) parse_args = Gh::Trending::Parsers::ParserArguments.new(*args) repos_list.clear repos_list << @parser.parse(parse_args).to_a.compact repos_list.flatten! end |
#to_h ⇒ Object
30 31 32 |
# File 'lib/gh_trending/repositories.rb', line 30 def to_h repos_list.map(&:to_h) end |