Class: Dslimple::Zone
- Inherits:
-
Object
- Object
- Dslimple::Zone
- Defined in:
- lib/dslimple/zone.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#records ⇒ Object
Returns the value of attribute records.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #===(other) ⇒ Object
- #clean_records(ignores) ⇒ Object
- #hash ⇒ Object
-
#initialize(name) ⇒ Zone
constructor
A new instance of Zone.
- #to_dsl(options = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Zone
Returns a new instance of Zone.
8 9 10 11 |
# File 'lib/dslimple/zone.rb', line 8 def initialize(name) @name = name @records = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/dslimple/zone.rb', line 5 def name @name end |
#records ⇒ Object
Returns the value of attribute records.
6 7 8 |
# File 'lib/dslimple/zone.rb', line 6 def records @records end |
Instance Method Details
#==(other) ⇒ Object
13 14 15 |
# File 'lib/dslimple/zone.rb', line 13 def ==(other) other.is_a?(self.class) && hash == other.hash && records.hash == other.records.hash end |
#===(other) ⇒ Object
17 18 19 |
# File 'lib/dslimple/zone.rb', line 17 def ===(other) other.is_a?(self.class) && hash == other.hash end |
#clean_records(ignores) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/dslimple/zone.rb', line 37 def clean_records(ignores) ignores = [ignores].flatten.map(&:to_s) records.select do |record| next false if ignores.include?('system') && record.system_record? next false if ignores.include?('child') && record.child_record? true end end |
#hash ⇒ Object
21 22 23 |
# File 'lib/dslimple/zone.rb', line 21 def hash [name, records.map(&:hash)].hash end |
#to_dsl(options = {}) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/dslimple/zone.rb', line 29 def to_dsl( = {}) <<DSL zone #{name.inspect} do #{clean_records([:ignore]).map { |record| record.to_dsl() }.join("\n\n")} end DSL end |
#to_s ⇒ Object
25 26 27 |
# File 'lib/dslimple/zone.rb', line 25 def to_s name end |