Sha256: 2ed4389317eb37d11e106b8f5bb8a5b78c7523574e75fb69c4bbd356521d8ca8
Contents?: true
Size: 895 Bytes
Versions: 1
Compression:
Stored size: 895 Bytes
Contents
require "attentive/entity" require "attentive/duration" require "attentive/entities/core/time/duration/units" Attentive::Entity.define "core.time.duration.single", "{{n:core.number.integer.positive}} {{unit:core.time.duration.units}}", published: false do |match| unit = match["unit"] n = match["n"] Attentive::Duration.new(unit => n) end Attentive::Entity.define "core.time.duration", %q{(?:(?<hours>\d\d?):(?<minutes>\d\d):(?<seconds>\d\d))}, "{{a:core.time.duration.single}} {{b:core.time.duration}}", "{{a:core.time.duration.single}} and {{b:core.time.duration}}", "{{a:core.time.duration.single}}" do |match| if match.matched?("hours") return Attentive::Duration.new( hours: match["hours"], minutes: match["minutes"], seconds: match["seconds"]) else a = match["a"] a += match["b"] if match.matched?("b") a end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
attentive-0.3.4 | lib/attentive/entities/core/time/duration.rb |