Class: Prune::PObjects::PHexadecimalString

Inherits:
Base
  • Object
show all
Defined in:
lib/prune/p_objects/p_hexadecimal_string.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#indent!, #outdent!, #space, #value_to_s

Constructor Details

#initialize(string) ⇒ PHexadecimalString

Returns a new instance of PHexadecimalString.



8
9
10
11
12
13
14
# File 'lib/prune/p_objects/p_hexadecimal_string.rb', line 8

def initialize(string)
  raise PHexadecimalStringTypeError unless
    string.instance_of?(String)
  @string = string.upcase
  raise PHexadecimalStringContentError unless
    /[0-9A-F]+/ === @string
end

Instance Attribute Details

#stringObject (readonly)

Returns the value of attribute string.



6
7
8
# File 'lib/prune/p_objects/p_hexadecimal_string.rb', line 6

def string
  @string
end

Instance Method Details

#==(value) ⇒ Object



16
17
18
19
# File 'lib/prune/p_objects/p_hexadecimal_string.rb', line 16

def ==(value)
  false unless value.instance_of?(self.class)
  @string == value.string
end

#to_sObject



21
22
23
# File 'lib/prune/p_objects/p_hexadecimal_string.rb', line 21

def to_s
  "<#{@string}>"
end