Module: JSONSchemer::Format::Duration
- Included in:
- JSONSchemer::Format
- Defined in:
- lib/json_schemer/format/duration.rb
Constant Summary collapse
- DUR_SECOND =
'\d+S'
- DUR_MINUTE =
dur-second = 1*DIGIT “S”
"\\d+M(#{DUR_SECOND})?"
- DUR_HOUR =
dur-hour = 1*DIGIT “H” [dur-minute]
"\\d+H(#{DUR_MINUTE})?"
- DUR_TIME =
dur-time = “T” (dur-hour / dur-minute / dur-second)
"T(#{DUR_HOUR}|#{DUR_MINUTE}|#{DUR_SECOND})"
- DUR_DAY =
dur-day = 1*DIGIT “D”
'\d+D'
- DUR_WEEK =
dur-week = 1*DIGIT “W”
'\d+W'
- DUR_MONTH =
dur-month = 1*DIGIT “M” [dur-day]
"\\d+M(#{DUR_DAY})?"
- DUR_YEAR =
dur-year = 1*DIGIT “Y” [dur-month]
"\\d+Y(#{DUR_MONTH})?"
- DUR_DATE =
dur-date = (dur-day / dur-month / dur-year) [dur-time]
"(#{DUR_DAY}|#{DUR_MONTH}|#{DUR_YEAR})(#{DUR_TIME})?"
- DURATION =
duration = “P” (dur-date / dur-time / dur-week)
"P(#{DUR_DATE}|#{DUR_TIME}|#{DUR_WEEK})"
- DURATION_REGEX =
/\A#{DURATION}\z/
Instance Method Summary collapse
Instance Method Details
#valid_duration?(data) ⇒ Boolean
18 19 20 |
# File 'lib/json_schemer/format/duration.rb', line 18 def valid_duration?(data) DURATION_REGEX.match?(data) end |