Class: Gh::Trending::Parsers::ParserArguments
- Inherits:
-
Object
- Object
- Gh::Trending::Parsers::ParserArguments
- Defined in:
- lib/gh_trending/parsers/parser_arguments.rb
Overview
This class represents the arguments that both the trending repositories and languages repositories accept.
If these pages accept new arguments, just add a new method here like:
def new_arg
args[:arg_name]
end
Also, complete the no_args? method.
Constant Summary collapse
- UnknownTimePeriod =
Class.new(StandardError)
- TIME_PERIOD_ARG =
:time_period
- LANGUAGE_ARG =
:language
- KNOWN_TIME_PERIODS =
%i[daily weekly monthly].freeze
- DEFAULT_TIME_PERIOD =
KNOWN_TIME_PERIODS.first
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Instance Method Summary collapse
-
#initialize(**args) ⇒ ParserArguments
constructor
A new instance of ParserArguments.
- #language ⇒ Object
- #no_args? ⇒ Boolean
- #time_period ⇒ Object
Constructor Details
#initialize(**args) ⇒ ParserArguments
Returns a new instance of ParserArguments.
24 25 26 27 |
# File 'lib/gh_trending/parsers/parser_arguments.rb', line 24 def initialize(**args) @args = args @args = {} if @args.empty? end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
15 16 17 |
# File 'lib/gh_trending/parsers/parser_arguments.rb', line 15 def args @args end |
Instance Method Details
#language ⇒ Object
33 34 35 |
# File 'lib/gh_trending/parsers/parser_arguments.rb', line 33 def language args[LANGUAGE_ARG] end |
#no_args? ⇒ Boolean
37 38 39 |
# File 'lib/gh_trending/parsers/parser_arguments.rb', line 37 def no_args? time_period.nil? && language.nil? end |
#time_period ⇒ Object
29 30 31 |
# File 'lib/gh_trending/parsers/parser_arguments.rb', line 29 def time_period sanitize_time_period(args[TIME_PERIOD_ARG]) end |