class Deb822::FieldName

Constants

PATTERN

> The field name is composed of US-ASCII characters excluding control characters, space, and colon > (i.e., characters in the ranges U+0021 ‘!’ through U+0039 ‘9’, and U+003B ‘;’ through U+007E ‘~’, inclusive). > Field names must not begin with the comment character (U+0023 ‘#’), nor with the hyphen character (U+002D ‘-’).

Public Class Methods

canonicalize(str) click to toggle source
# File lib/deb822.rb, line 61
def self.canonicalize(str)
  str.split(?-).each {|s| s.capitalize!(:ascii) }.join(?-)
end
new(name) click to toggle source
# File lib/deb822.rb, line 23
def initialize(name)
  name = name.to_s unless name.is_a?(String)

  unless /\A#{PATTERN}\z/o.match?(name)
    raise InvalidFieldName, "Invalid field name: #{name.inspect}"
  end

  @sym = FieldName.canonicalize(name).to_sym
end

Public Instance Methods

!=(other) click to toggle source
# File lib/deb822.rb, line 53
def !=(other)
  !eql?(other)
end
==(other) click to toggle source
# File lib/deb822.rb, line 49
def ==(other)
  eql?(other)
end
eql?(other) click to toggle source
# File lib/deb822.rb, line 45
def eql?(other)
  to_sym == Deb822::FieldName(other).to_sym
end
hash() click to toggle source
# File lib/deb822.rb, line 41
def hash
  @sym.hash
end
inspect() click to toggle source
# File lib/deb822.rb, line 57
def inspect
  @sym
end
to_s() click to toggle source
# File lib/deb822.rb, line 37
def to_s
  @sym.to_s
end
to_sym() click to toggle source
# File lib/deb822.rb, line 33
def to_sym
  @sym
end