2014-01-18 13:12:10 +00:00
|
|
|
class PlaybackOptions
|
|
|
|
|
2015-10-13 18:38:37 +00:00
|
|
|
class Time < Virtus::Attribute
|
|
|
|
def coerce(value)
|
|
|
|
value = value.presence
|
|
|
|
|
|
|
|
if value
|
|
|
|
smh = value.strip.sub("m", ":0").split(":").reverse
|
|
|
|
smh[0].to_i + smh[1].to_i * 60 + smh[2].to_i * 3600
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-18 13:12:10 +00:00
|
|
|
include Virtus.model
|
|
|
|
|
|
|
|
attribute :speed, Float, default: 1.0
|
2014-01-18 13:19:23 +00:00
|
|
|
attribute :size, String, default: 'small'
|
2015-10-13 18:38:37 +00:00
|
|
|
attribute :autoplay, Boolean
|
2014-08-09 11:09:54 +00:00
|
|
|
attribute :loop, Boolean, default: false
|
2014-01-18 13:12:10 +00:00
|
|
|
attribute :benchmark, Boolean, default: false
|
2014-06-30 21:26:25 +00:00
|
|
|
attribute :theme, String, default: Theme::DEFAULT
|
2015-10-13 18:38:37 +00:00
|
|
|
attribute :t, Time
|
2014-01-18 13:12:10 +00:00
|
|
|
|
2015-10-08 09:55:14 +00:00
|
|
|
def as_json(*)
|
2015-10-13 18:38:37 +00:00
|
|
|
opts = {
|
2015-10-08 09:55:14 +00:00
|
|
|
speed: speed,
|
|
|
|
autoPlay: autoplay,
|
|
|
|
loop: loop,
|
|
|
|
fontSize: size,
|
2015-10-13 18:38:37 +00:00
|
|
|
theme: theme,
|
2015-10-08 09:55:14 +00:00
|
|
|
}
|
2015-10-13 18:38:37 +00:00
|
|
|
|
|
|
|
if t
|
|
|
|
opts = opts.merge(startAt: t)
|
|
|
|
end
|
|
|
|
|
|
|
|
opts
|
2015-10-08 09:55:14 +00:00
|
|
|
end
|
|
|
|
|
2014-01-18 13:12:10 +00:00
|
|
|
end
|