Class: AfterTheDeadline::Error
- Inherits:
-
Object
- Object
- AfterTheDeadline::Error
- Defined in:
- lib/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.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
- #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.
83 84 85 86 87 88 89 |
# File 'lib/after_the_deadline.rb', line 83 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.
81 82 83 |
# File 'lib/after_the_deadline.rb', line 81 def description @description end |
#precontext ⇒ Object
Returns the value of attribute precontext.
81 82 83 |
# File 'lib/after_the_deadline.rb', line 81 def precontext @precontext end |
#string ⇒ Object
Returns the value of attribute string.
81 82 83 |
# File 'lib/after_the_deadline.rb', line 81 def string @string end |
#suggestions ⇒ Object
Returns the value of attribute suggestions.
81 82 83 |
# File 'lib/after_the_deadline.rb', line 81 def suggestions @suggestions end |
#type ⇒ Object
Returns the value of attribute type.
81 82 83 |
# File 'lib/after_the_deadline.rb', line 81 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
81 82 83 |
# File 'lib/after_the_deadline.rb', line 81 def url @url end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
102 103 104 105 106 107 |
# File 'lib/after_the_deadline.rb', line 102 def eql?(other) self.class.equal?(other.class) && string == other.string && description == other.description && type == other.type end |
#hash ⇒ Object
110 111 112 |
# File 'lib/after_the_deadline.rb', line 110 def hash string.hash ^ description.hash ^ type.hash end |
#info(theme = nil) ⇒ Object
91 92 93 94 95 96 |
# File 'lib/after_the_deadline.rb', line 91 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
98 99 100 |
# File 'lib/after_the_deadline.rb', line 98 def to_s "#{self.string} (#{self.description})" end |