Class: DroneApi::Strike
- Inherits:
-
Object
- Object
- DroneApi::Strike
- Defined in:
- lib/drone_api/strike.rb
Instance Attribute Summary collapse
-
#articles ⇒ Object
readonly
Returns the value of attribute articles.
-
#bij_link ⇒ Object
readonly
Returns the value of attribute bij_link.
-
#bij_summary_short ⇒ Object
readonly
Returns the value of attribute bij_summary_short.
-
#bureau_id ⇒ Object
readonly
Returns the value of attribute bureau_id.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#civilians ⇒ Object
readonly
Returns the value of attribute civilians.
-
#country ⇒ Object
readonly
Returns the value of attribute country.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#deaths ⇒ Object
readonly
Returns the value of attribute deaths.
-
#deaths_max ⇒ Object
readonly
Returns the value of attribute deaths_max.
-
#deaths_min ⇒ Object
readonly
Returns the value of attribute deaths_min.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#injuries ⇒ Object
readonly
Returns the value of attribute injuries.
-
#lat ⇒ Object
readonly
Returns the value of attribute lat.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#lon ⇒ Object
readonly
Returns the value of attribute lon.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#town ⇒ Object
readonly
Returns the value of attribute town.
-
#tweet_id ⇒ Object
readonly
Returns the value of attribute tweet_id.
Class Method Summary collapse
-
.parse(js) ⇒ Object
Return array of Strike objects from json string.
Instance Method Summary collapse
-
#initialize(data = nil) ⇒ Strike
constructor
Initialize attributes.
Constructor Details
#initialize(data = nil) ⇒ Strike
Initialize attributes
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 52 53 54 |
# File 'lib/drone_api/strike.rb', line 27 def initialize(data = nil) unless data.nil? data = JSON.parse(data) if data.is_a? String @id = parse_string(data['_id']) @number = parse_int(data['number']) @country = parse_string(data['country']) @date = parse_date(data['date']) @town = parse_string(data['town']) @location = parse_string(data['location']) @deaths = parse_int(data['deaths']) @deaths_min = parse_int(data['deaths_min']) @deaths_max = parse_int(data['deaths_max']) @civilians = parse_int(data['civilians']) @injuries = parse_int(data['injuries']) @children = parse_int(data['children']) @tweet_id = parse_string(data['tweet_id']) @bureau_id = parse_string(data['bureau_id']) @summary_short = parse_string(data['bij_summary_short']) @link = parse_string(data['bij_link']) @target = parse_string(data['target']) @lat = parse_string(data['lat']) @lon = parse_string(data['lon']) @articles = parse_string(data['articles']) @names = parse_string(data['names']) end end |
Instance Attribute Details
#articles ⇒ Object (readonly)
Returns the value of attribute articles.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def articles @articles end |
#bij_link ⇒ Object (readonly)
Returns the value of attribute bij_link.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def bij_link @bij_link end |
#bij_summary_short ⇒ Object (readonly)
Returns the value of attribute bij_summary_short.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def bij_summary_short @bij_summary_short end |
#bureau_id ⇒ Object (readonly)
Returns the value of attribute bureau_id.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def bureau_id @bureau_id end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def children @children end |
#civilians ⇒ Object (readonly)
Returns the value of attribute civilians.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def civilians @civilians end |
#country ⇒ Object (readonly)
Returns the value of attribute country.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def country @country end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def date @date end |
#deaths ⇒ Object (readonly)
Returns the value of attribute deaths.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def deaths @deaths end |
#deaths_max ⇒ Object (readonly)
Returns the value of attribute deaths_max.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def deaths_max @deaths_max end |
#deaths_min ⇒ Object (readonly)
Returns the value of attribute deaths_min.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def deaths_min @deaths_min end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def id @id end |
#injuries ⇒ Object (readonly)
Returns the value of attribute injuries.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def injuries @injuries end |
#lat ⇒ Object (readonly)
Returns the value of attribute lat.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def lat @lat end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def location @location end |
#lon ⇒ Object (readonly)
Returns the value of attribute lon.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def lon @lon end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def names @names end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def number @number end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def target @target end |
#town ⇒ Object (readonly)
Returns the value of attribute town.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def town @town end |
#tweet_id ⇒ Object (readonly)
Returns the value of attribute tweet_id.
6 7 8 |
# File 'lib/drone_api/strike.rb', line 6 def tweet_id @tweet_id end |
Class Method Details
.parse(js) ⇒ Object
Return array of Strike objects from json string
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/drone_api/strike.rb', line 13 def self.parse(js) data = JSON.parse(js) strikes = [] data['strike'].each do |s| strike = Strike.new s strikes << strike end unless data['strike'].nil? or data['strike'].empty? return strikes end |