Class: Galerts::Alert
- Inherits:
-
Object
- Object
- Galerts::Alert
- Defined in:
- lib/galerts/alert.rb
Instance Attribute Summary collapse
-
#data_id ⇒ Object
Returns the value of attribute data_id.
-
#data_id_2 ⇒ Object
Returns the value of attribute data_id_2.
-
#delivery ⇒ Object
Returns the value of attribute delivery.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#feed_url ⇒ Object
Returns the value of attribute feed_url.
-
#frequency ⇒ Object
Returns the value of attribute frequency.
-
#how_many ⇒ Object
Returns the value of attribute how_many.
-
#id ⇒ Object
Returns the value of attribute id.
-
#language ⇒ Object
Returns the value of attribute language.
-
#query ⇒ Object
Returns the value of attribute query.
-
#region ⇒ Object
Returns the value of attribute region.
-
#sources ⇒ Object
Returns the value of attribute sources.
Instance Method Summary collapse
-
#initialize(query, options = {}) ⇒ Alert
constructor
A new instance of Alert.
Constructor Details
#initialize(query, options = {}) ⇒ Alert
Returns a new instance of Alert.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/galerts/alert.rb', line 4 def initialize(query, = {}) = { id: 0, data_id: 0, data_id_2: 0, domain: DOMAIN, frequency: RT, sources: AUTOMATIC, language: LANGUAGE, how_many: ALL_RESULTS, region: ANYWHERE, delivery: RSS, feed_url: nil } .each do |key, value| [key] ||= value end # check options type raise "Unknown alert how many" unless HOW_MANY_TYPES.has_key?([:how_many]) raise "Unknown alert delivery type" unless DELIVERY_TYPES.has_key?([:delivery]) raise "Unknown alert frequency type" unless FREQ_TYPES.has_key?([:frequency]) if [:sources].kind_of?(Array) [:sources].collect do |source| raise "Unknown alert source in Array" unless SOURCES_TYPES.has_key?(source) end elsif [:sources].nil? raise "Nil alert source" elsif !SOURCES_TYPES.has_key?([:sources]) raise "Unknown alert source" end @query = query @id = [:id] @data_id = [:data_id] @data_id_2 = [:data_id_2] @domain = [:domain] @frequency = [:frequency] @sources = [:sources] @language = [:language] @how_many = [:how_many] @region = [:region] @delivery = [:delivery] @feed_url = [:feed_url] end |
Instance Attribute Details
#data_id ⇒ Object
Returns the value of attribute data_id.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def data_id @data_id end |
#data_id_2 ⇒ Object
Returns the value of attribute data_id_2.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def data_id_2 @data_id_2 end |
#delivery ⇒ Object
Returns the value of attribute delivery.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def delivery @delivery end |
#domain ⇒ Object
Returns the value of attribute domain.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def domain @domain end |
#feed_url ⇒ Object
Returns the value of attribute feed_url.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def feed_url @feed_url end |
#frequency ⇒ Object
Returns the value of attribute frequency.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def frequency @frequency end |
#how_many ⇒ Object
Returns the value of attribute how_many.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def how_many @how_many end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def id @id end |
#language ⇒ Object
Returns the value of attribute language.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def language @language end |
#query ⇒ Object
Returns the value of attribute query.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def query @query end |
#region ⇒ Object
Returns the value of attribute region.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def region @region end |
#sources ⇒ Object
Returns the value of attribute sources.
3 4 5 |
# File 'lib/galerts/alert.rb', line 3 def sources @sources end |