lib/iso8601/duration.rb in iso8601-basic-0.1.0 vs lib/iso8601/duration.rb in iso8601-basic-0.1.1

- old
+ new

@@ -62,21 +62,29 @@ def ==(other) eql? other end def hash - [self.class, to_h.to_a].hash + [self.class, to_a].hash end def inspect "#<#{self.class.name}: #{iso8601}>" end def to_s iso8601 end + def as_json + iso8601 + end + + def to_json + "\"#{iso8601}\"" + end + def format singular = { years: 'year', months: 'month', weeks: 'week', @@ -103,9 +111,13 @@ end.inject :+ end def to_i to_f.to_i + end + + def to_a + to_h.to_a end def to_h { years: @years, months: @months, \ No newline at end of file