2024-06-26

ActiveSupport::Duration

https://api.rubyonrails.org/classes/ActiveSupport/Duration.html#method-i-parts

> ActiveSupport::Duration.build(2562)
=> 42 minutes and 42 seconds
> ActiveSupport::Duration.build(2562).parts
=> {:minutes=>42, :seconds=>42}

=> {:duration=>3600}
> ActiveSupport::Duration.build(video[:duration]).parts
=> {:hours=>1}
> ActiveSupport::Duration.build(video[:duration]).parts[:hours]
=> 1

> duration = ActiveSupport::Duration.build(video[:duration]).parts
=> {:hours=>1}

> duration[:hours]
=> 1

他にもこういうのがあるのか〜

> 12.hours.class
=> ActiveSupport::Duration
> 12.hours.in_days
=> 0.5
> 1.day.in_hours
=> 24.0