class AfterTheDeadline::Error

Attributes

description[RW]
precontext[RW]
string[RW]
suggestions[RW]
type[RW]
url[RW]

Public Class Methods

new(hash) click to toggle source
# File lib/after_the_deadline.rb, line 96
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

Public Instance Methods

==(other)
Alias for: eql?
eql?(other) click to toggle source
# File lib/after_the_deadline.rb, line 115
def eql?(other)
  self.class.equal?(other.class) &&
    string == other.string &&
    description == other.description &&
    type == other.type
end
Also aliased as: ==
hash() click to toggle source
# File lib/after_the_deadline.rb, line 123
def hash
  string.hash ^ description.hash ^ type.hash
end
info(theme = nil) click to toggle source
# File lib/after_the_deadline.rb, line 104
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() click to toggle source
# File lib/after_the_deadline.rb, line 111
def to_s
  "#{self.string} (#{self.description})"
end