Class: MassShootings::Shooting

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::AttributeMethods
Defined in:
lib/mass_shootings/shooting.rb

Overview

A ‘MassShooting::Shooting` is when four or more people are shot in an event, or related series of events, likely without a cooling off period.

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Shooting

Creates a new Shooting with the given attributes.

Parameters:

  • attributes (Hash)

    Information pertaining to the Shooting.

Options Hash (attributes):

  • id (String)

    a unique identifier

  • alleged_shooters (Array<String>) — default: nil

    the names of the alleged shooters

  • casualties (Hash{Symbol => Integer})

    count of casualties, classified by type (‘:dead` or `:injured`)

  • date (Date)

    date the shooting occurred

  • location (String)

    where the shooting occurred

  • references (Array<URI>)

    links to relevant news sources



34
35
36
# File 'lib/mass_shootings/shooting.rb', line 34

def initialize(attributes)
  @attributes = attributes
end

Instance Method Details

#attribute(name) ⇒ Object

Retrieves an attribute by name.



17
18
19
# File 'lib/mass_shootings/shooting.rb', line 17

def attribute(name)
  @attributes[name.to_sym]
end