module ConditionalSample
Public Class Methods
method_assert(object, method_name)
click to toggle source
Raise an error if an object does not respond to a specific method.
# File lib/conditional_sample.rb, line 21 def self.method_assert object, method_name unless object.respond_to?(method_name) raise NoMethodError, "Missing method ##{method_name}" end end
to_conditions_array(input, default = nil)
click to toggle source
Convert a hash to array, with key as index. Fill any missing elements with a default value.
# File lib/conditional_sample.rb, line 31 def self.to_conditions_array input, default = nil return input if input.is_a? Array # Get a list of all Integer keys. # Use the biggest key, and make an array of that length + 1. keys = input.keys.select { |i| i.is_a? Integer } keys.max.next.times.map { |i| input[i] || default } end
version_date()
click to toggle source
The date of the current version.
# File lib/conditional_sample/version.rb, line 21 def self.version_date '2017-06-30' end
version_number()
click to toggle source
The number of the current version.
# File lib/conditional_sample/version.rb, line 9 def self.version_number major = 1 minor = 0 tiny = 0 pre = nil string = [major, minor, tiny, pre].compact.join('.') end