Class: AfterTheDeadline::Error

Inherits:
Merimee::Error show all
Defined in:
lib/merimee/after_the_deadline.rb

Instance Attribute Summary collapse

Attributes inherited from Merimee::Error

#severity

Instance Method Summary collapse

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

#descriptionObject

Returns the value of attribute description


57
58
59
# File 'lib/merimee/after_the_deadline.rb', line 57

def description
  @description
end

#precontextObject

Returns the value of attribute precontext


57
58
59
# File 'lib/merimee/after_the_deadline.rb', line 57

def precontext
  @precontext
end

#stringObject

Returns the value of attribute string


57
58
59
# File 'lib/merimee/after_the_deadline.rb', line 57

def string
  @string
end

#suggestionsObject

Returns the value of attribute suggestions


57
58
59
# File 'lib/merimee/after_the_deadline.rb', line 57

def suggestions
  @suggestions
end

#typeObject

Returns the value of attribute type


57
58
59
# File 'lib/merimee/after_the_deadline.rb', line 57

def type
  @type
end

#urlObject

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_sObject


74
75
76
# File 'lib/merimee/after_the_deadline.rb', line 74

def to_s
  "#{self.string} (#{self.description})"
end