class Gh::Trending::Parsers::ParserArguments
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.
Constants
- DEFAULT_TIME_PERIOD
- KNOWN_TIME_PERIODS
- LANGUAGE_ARG
- TIME_PERIOD_ARG
- UnknownTimePeriod
Attributes
args[R]
Public Class Methods
new(**args)
click to toggle source
# File lib/gh_trending/parsers/parser_arguments.rb, line 24 def initialize(**args) @args = args @args = {} if @args.empty? end
Public Instance Methods
language()
click to toggle source
# File lib/gh_trending/parsers/parser_arguments.rb, line 33 def language args[LANGUAGE_ARG] end
no_args?()
click to toggle source
# File lib/gh_trending/parsers/parser_arguments.rb, line 37 def no_args? time_period.nil? && language.nil? end
time_period()
click to toggle source
# File lib/gh_trending/parsers/parser_arguments.rb, line 29 def time_period sanitize_time_period(args[TIME_PERIOD_ARG]) end
Private Instance Methods
sanitize_time_period(time_period)
click to toggle source
# File lib/gh_trending/parsers/parser_arguments.rb, line 43 def sanitize_time_period(time_period) return nil if time_period.nil? unless KNOWN_TIME_PERIODS.include? time_period error_msg = "The time period '#{time_period}' is invalid. " \ "Supported: #{KNOWN_TIME_PERIODS}" raise UnknownTimePeriod.new(error_msg) end time_period end