Class: AfterTheDeadline::Error
- Inherits:
-
Merimee::Error
- Object
- Merimee::Error
- AfterTheDeadline::Error
- Defined in:
- lib/merimee/after_the_deadline.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#precontext ⇒ Object
readonly
Returns the value of attribute precontext.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
-
#suggestions ⇒ Object
readonly
Returns the value of attribute suggestions.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from Merimee::Error
Instance Method Summary collapse
- #info(theme = nil) ⇒ Object
-
#initialize(hash) ⇒ Error
constructor
A new instance of Error.
- #to_s ⇒ Object
Constructor Details
#initialize(hash) ⇒ Error
Returns a new instance of Error.
59 60 61 62 63 64 65 |
# File 'lib/merimee/after_the_deadline.rb', line 59 def initialize(hash) raise "#{self.class} must be initialized with a Hash" unless hash.kind_of?(Hash) [:string, :description, :precontext, :type, :url].each do |attribute| self.send("#{attribute}=", hash[attribute.to_s]) end self.suggestions = hash['suggestions'].nil? ? [] : [*hash['suggestions']['option']] end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
57 58 59 |
# File 'lib/merimee/after_the_deadline.rb', line 57 def description @description end |
#precontext ⇒ Object
Returns the value of attribute precontext.
57 58 59 |
# File 'lib/merimee/after_the_deadline.rb', line 57 def precontext @precontext end |
#string ⇒ Object
Returns the value of attribute string.
57 58 59 |
# File 'lib/merimee/after_the_deadline.rb', line 57 def string @string end |
#suggestions ⇒ Object
Returns the value of attribute suggestions.
57 58 59 |
# File 'lib/merimee/after_the_deadline.rb', line 57 def suggestions @suggestions end |
#type ⇒ Object
Returns the value of attribute type.
57 58 59 |
# File 'lib/merimee/after_the_deadline.rb', line 57 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
57 58 59 |
# File 'lib/merimee/after_the_deadline.rb', line 57 def url @url end |
Instance Method Details
#info(theme = nil) ⇒ Object
67 68 69 70 71 72 |
# File 'lib/merimee/after_the_deadline.rb', line 67 def info(theme = nil) return unless self.url uri = URI.parse self.url uri.query = (uri.query || '') + "&theme=#{theme}" Net::HTTP.get(uri).strip end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/merimee/after_the_deadline.rb', line 74 def to_s "#{self.string} (#{self.description})" end |