Class: Zonesync::Record

Inherits:
Struct
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/zonesync/record.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commentObject

Returns the value of attribute comment

Returns:

  • (Object)

    the current value of comment



5
6
7
# File 'lib/zonesync/record.rb', line 5

def comment
  @comment
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/zonesync/record.rb', line 5

def name
  @name
end

#rdataObject

Returns the value of attribute rdata

Returns:

  • (Object)

    the current value of rdata



5
6
7
# File 'lib/zonesync/record.rb', line 5

def rdata
  @rdata
end

#ttlObject

Returns the value of attribute ttl

Returns:

  • (Object)

    the current value of ttl



5
6
7
# File 'lib/zonesync/record.rb', line 5

def ttl
  @ttl
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



5
6
7
# File 'lib/zonesync/record.rb', line 5

def type
  @type
end

Class Method Details

.from_dns_zonefile_record(record) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/zonesync/record.rb', line 9

def self.from_dns_zonefile_record record
  new(
    name: record.host,
    type: record.type,
    ttl: record.ttl,
    rdata: record.rdata,
    comment: record.comment,
  )
end

Instance Method Details

#<=>(other) ⇒ Object



40
41
42
# File 'lib/zonesync/record.rb', line 40

def <=> other
  to_sortable <=> other.to_sortable
end

#checksum?Boolean

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/zonesync/record.rb', line 34

def checksum?
  type == "TXT" &&
    name.match?(/^zonesync_checksum\./)
end

#manifest?Boolean

Returns:

  • (Boolean)


28
29
30
31
# File 'lib/zonesync/record.rb', line 28

def manifest?
  type == "TXT" &&
    name.match?(/^zonesync_manifest\./)
end

#short_name(origin) ⇒ Object



20
21
22
23
24
25
# File 'lib/zonesync/record.rb', line 20

def short_name origin
  ret = name.sub(origin, "")
  ret = ret.sub(/\.$/, "")
  ret = "@" if ret == ""
  ret
end

#to_sObject



51
52
53
54
55
# File 'lib/zonesync/record.rb', line 51

def to_s
  string = [name, ttl, type, rdata].join(" ")
  string << " ; #{comment}" if comment
  string
end

#to_sortableObject



45
46
47
48
# File 'lib/zonesync/record.rb', line 45

def to_sortable
  is_soa = type == "SOA" ? 0 : 1
  [is_soa, type, name, rdata, ttl.to_i]
end