class SyoboiCalendar::Queries::BaseQuery
Attributes
property_names[W]
Public Class Methods
inherited(child_class)
click to toggle source
@note Override
# File lib/syoboi_calendar/queries/base_query.rb, line 8 def inherited(child_class) child_class.property_names = property_names.clone end
new(options = {})
click to toggle source
@param options [Hash]
# File lib/syoboi_calendar/queries/base_query.rb, line 27 def initialize(options = {}) @options = options end
property(property_name)
click to toggle source
@param property_name [Symbol]
# File lib/syoboi_calendar/queries/base_query.rb, line 18 def property(property_name) property_names << property_name end
property_names()
click to toggle source
@return [Array<Symbol>]
# File lib/syoboi_calendar/queries/base_query.rb, line 13 def property_names @property_names ||= [] end
Public Instance Methods
Command()
click to toggle source
@return [String]
# File lib/syoboi_calendar/queries/base_query.rb, line 32 def Command raise ::NotImplementedError end
LastUpdate()
click to toggle source
@return [String, nil]
# File lib/syoboi_calendar/queries/base_query.rb, line 37 def LastUpdate format_time_range(options[:updated_from], options[:updated_to]) end
to_hash()
click to toggle source
@return [Hash]
# File lib/syoboi_calendar/queries/base_query.rb, line 42 def to_hash self.class.property_names.each_with_object({}) do |property_name, result| value = send(property_name) unless value.nil? result[property_name.to_s] = value end end end
Private Instance Methods
format_comma_separated_values(value_or_values)
click to toggle source
@private @param value_or_values [Array, Integer, String] @return [String]
# File lib/syoboi_calendar/queries/base_query.rb, line 56 def format_comma_separated_values(value_or_values) Array(value_or_values).join(",") end
format_time(time)
click to toggle source
@private @param [Time, nil] @return [String]
# File lib/syoboi_calendar/queries/base_query.rb, line 63 def format_time(time) if time time.strftime("%Y%m%d_%H%M%S") end end
format_time_range(started_at, finished_at)
click to toggle source
@private @param started_at [Time, nil] @param finished_at [Time, nil]
# File lib/syoboi_calendar/queries/base_query.rb, line 72 def format_time_range(started_at, finished_at) if started_at || finished_at [ format_time(started_at), format_time(finished_at), ].join("-") end end
options()
click to toggle source
@private @return [Hash]
# File lib/syoboi_calendar/queries/base_query.rb, line 83 def options @options end