Class: CountryDiscoverySite
- Inherits:
-
Domain::Model
- Object
- Domain::Model
- CountryDiscoverySite
- Defined in:
- lib/domain/site/model.rb
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#network_zone ⇒ Object
Returns the value of attribute network_zone.
-
#scan_engine ⇒ Object
Returns the value of attribute scan_engine.
-
#scan_template ⇒ Object
Returns the value of attribute scan_template.
Class Method Summary collapse
-
.country(site_name) ⇒ Object
Extract the country between the start of the site name end the first occurence of the words [DMZ,Core,Data Centre].
- .network_zone(site_name) ⇒ Object
- .table_name ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ CountryDiscoverySite
constructor
A new instance of CountryDiscoverySite.
Methods inherited from Domain::Model
columns, from_csv, from_json, headers, primary_key, #to_csv, #to_hash, #to_s, view
Constructor Details
#initialize(attributes = {}) ⇒ CountryDiscoverySite
Returns a new instance of CountryDiscoverySite.
166 167 168 169 170 |
# File 'lib/domain/site/model.rb', line 166 def initialize(attributes = {}) attributes[:country] ||= self.class.country(attributes[:name]) if attributes[:name] attributes[:network_zone] ||= self.class.network_zone(attributes[:name]) if attributes[:name] super(attributes) end |
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country.
155 156 157 |
# File 'lib/domain/site/model.rb', line 155 def country @country end |
#id ⇒ Object
Returns the value of attribute id.
155 156 157 |
# File 'lib/domain/site/model.rb', line 155 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
155 156 157 |
# File 'lib/domain/site/model.rb', line 155 def name @name end |
#network_zone ⇒ Object
Returns the value of attribute network_zone.
155 156 157 |
# File 'lib/domain/site/model.rb', line 155 def network_zone @network_zone end |
#scan_engine ⇒ Object
Returns the value of attribute scan_engine.
155 156 157 |
# File 'lib/domain/site/model.rb', line 155 def scan_engine @scan_engine end |
#scan_template ⇒ Object
Returns the value of attribute scan_template.
155 156 157 |
# File 'lib/domain/site/model.rb', line 155 def scan_template @scan_template end |
Class Method Details
.country(site_name) ⇒ Object
Extract the country between the start of the site name end the first occurence of the words [DMZ,Core,Data Centre]
182 183 184 185 186 187 188 189 190 |
# File 'lib/domain/site/model.rb', line 182 def self.country(site_name) network_zone_pattern = /DMZ|Core|Data Centre/ parts = site_name.split(network_zone_pattern) if parts.length > 1 parts.first.strip else 'Unknown' end end |
.network_zone(site_name) ⇒ Object
172 173 174 175 176 177 178 |
# File 'lib/domain/site/model.rb', line 172 def self.network_zone(site_name) if site_name.include?('DMZ') 'dmz' else 'core' end end |
.table_name ⇒ Object
162 163 164 |
# File 'lib/domain/site/model.rb', line 162 def self.table_name 'country_discovery_site' end |