Class: Pubid::Nist::Edition
- Inherits:
-
Core::Entity
- Object
- Core::Entity
- Pubid::Nist::Edition
- Defined in:
- lib/pubid/nist/edition.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#month ⇒ Object
Returns the value of attribute month.
-
#number ⇒ Object
Returns the value of attribute number.
-
#parsed ⇒ Object
Returns the value of attribute parsed.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
-
#initialize(parsed: nil, year: nil, month: nil, day: nil, number: nil) ⇒ Edition
constructor
A new instance of Edition.
- #to_s(format: :short) ⇒ Object
Constructor Details
#initialize(parsed: nil, year: nil, month: nil, day: nil, number: nil) ⇒ Edition
Returns a new instance of Edition.
5 6 7 8 9 10 11 |
# File 'lib/pubid/nist/edition.rb', line 5 def initialize(parsed: nil, year: nil, month: nil, day: nil, number: nil) @parsed = parsed @year = year @month = month @day = day @number = number end |
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day.
3 4 5 |
# File 'lib/pubid/nist/edition.rb', line 3 def day @day end |
#month ⇒ Object
Returns the value of attribute month.
3 4 5 |
# File 'lib/pubid/nist/edition.rb', line 3 def month @month end |
#number ⇒ Object
Returns the value of attribute number.
3 4 5 |
# File 'lib/pubid/nist/edition.rb', line 3 def number @number end |
#parsed ⇒ Object
Returns the value of attribute parsed.
3 4 5 |
# File 'lib/pubid/nist/edition.rb', line 3 def parsed @parsed end |
#year ⇒ Object
Returns the value of attribute year.
3 4 5 |
# File 'lib/pubid/nist/edition.rb', line 3 def year @year end |
Instance Method Details
#to_s(format: :short) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pubid/nist/edition.rb', line 13 def to_s(format: :short) if format == :long result = (@number && ["Edition #{@number}"]) || [] if @day result << Date.new(@year, @month, @day).strftime("(%B %d, %Y)") elsif @month result << Date.new(@year, @month).strftime("(%B %Y)") elsif @year result << Date.new(@year).strftime("(%Y)") end result.join(" ") else result = (@number && [@number]) || [] if @day result << Date.new(@year, @month, @day).strftime("%Y%m%d") elsif @month result << Date.new(@year, @month).strftime("%Y%m") elsif @year result << Date.new(@year).strftime("%Y") end result.join("-") end end |