Skip to content

Instantly share code, notes, and snippets.

@adam12
Created September 17, 2015 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam12/d1acd0dafc26177b2282 to your computer and use it in GitHub Desktop.
Save adam12/d1acd0dafc26177b2282 to your computer and use it in GitHub Desktop.
class TimeSelectRange
attr_accessor :value
def initialize(value)
@value = value
end
def formatted(format = "%02d:%02d")
format % [value / 60 / 60, value / 60 % 60]
end
def self.build(start: 0, stop: 86400, step: 15.minutes)
start.step(stop, step).map {|value| new(value) }.each
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment