Class: EZDyn::RecordType
- Inherits:
-
Object
- Object
- EZDyn::RecordType
- Defined in:
- lib/ezdyn/record_type.rb
Overview
Encapsulates the properties of supported record types
Constant Summary collapse
- @@types =
[]
Instance Attribute Summary collapse
-
#uri_name ⇒ Object
readonly
The URI path element that signals this record type.
-
#value_key ⇒ Object
readonly
The dict key for this record type’s
rdatavalue.
Class Method Summary collapse
-
.find(to_find) ⇒ EZDyn::RecordType
Converts several possible representations of a RecordType into an appropriate class instance.
-
.valid_type?(t) ⇒ Boolean
Check if a type is valid.
Instance Method Summary collapse
-
#initialize(name:, uri_name:, value_key:) ⇒ RecordType
constructor
RecordType constructor.
-
#name ⇒ String
Provides an all-caps String representation of the record type, eg ‘A’,‘CNAME’.
-
#to_s ⇒ String
Converts the RecordType to the all-caps String of the record type.
Constructor Details
#initialize(name:, uri_name:, value_key:) ⇒ RecordType
RecordType constructor. In general there is no reason to call this method directly as all known record types are created at file load time. Instead the #find method is the preferred way to fetch a RecordType object.
27 28 29 30 31 32 |
# File 'lib/ezdyn/record_type.rb', line 27 def initialize(name:, uri_name:, value_key:) EZDyn.debug { "RecordType.new( name: #{name}, uri_name: #{uri_name}, value_key: #{value_key} )" } @name = name @uri_name = uri_name @value_key = value_key end |
Instance Attribute Details
#uri_name ⇒ Object (readonly)
The URI path element that signals this record type.
15 16 17 |
# File 'lib/ezdyn/record_type.rb', line 15 def uri_name @uri_name end |
#value_key ⇒ Object (readonly)
The dict key for this record type’s rdata value.
18 19 20 |
# File 'lib/ezdyn/record_type.rb', line 18 def value_key @value_key end |
Class Method Details
.find(to_find) ⇒ EZDyn::RecordType
Converts several possible representations of a RecordType into an appropriate class instance. Pass in a RecordType instance, a String or Symbol of the type name or the String fragment of a REST API URI.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ezdyn/record_type.rb', line 42 def self.find(to_find) EZDyn.debug { "RecordType#find( [#{to_find.class}] #{to_find} )" } if to_find.is_a? RecordType return to_find else return @@types.find { |ctype| ctype.name == to_find.to_s.upcase } || @@types.find { |ctype| ctype.uri_name.downcase == to_find.to_s.downcase } end EZDyn.debug { "No such RecordType was found" } end |
.valid_type?(t) ⇒ Boolean
Check if a type is valid.
10 11 12 |
# File 'lib/ezdyn/record_type.rb', line 10 def self.valid_type?(t) not RecordType.find(t).nil? end |
Instance Method Details
#name ⇒ String
Provides an all-caps String representation of the record type, eg ‘A’,‘CNAME’.
58 59 60 |
# File 'lib/ezdyn/record_type.rb', line 58 def name @name.to_s.upcase end |
#to_s ⇒ String
Converts the RecordType to the all-caps String of the record type.
65 66 67 |
# File 'lib/ezdyn/record_type.rb', line 65 def to_s self.name end |