class EZDyn::RecordType
Encapsulates the properties of supported record types
Attributes
The URI path element that signals this record type.
The dict key for this record type's `rdata` value.
Public Class Methods
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.
@param to_find [EZDyn::RecordType, String, Symbol] Representation of the
paramter to be found.
@return [EZDyn::RecordType] The class instance requested or `nil` if none
is found.
# 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
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.
@param name [Symbol] The canonical type of the record. @param uri_name
[String] URI path element for the record type. @param value_key
[String] Record
data value dict key.
# 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
Check if a type is valid.
@return [Boolean] Whether the type given is valid.
# File lib/ezdyn/record_type.rb, line 10 def self.valid_type?(t) not RecordType.find(t).nil? end
Public Instance Methods
Provides an all-caps String representation of the record type, eg 'A','CNAME'.
@return [String] The name of the record type.
# File lib/ezdyn/record_type.rb, line 58 def name @name.to_s.upcase end
Converts the RecordType
to the all-caps String of the record type.
@return [String] The displayable String representation.
# File lib/ezdyn/record_type.rb, line 65 def to_s self.name end