Class: ImmosquareConstants::Ip::IpResult

Inherits:
Object
  • Object
show all
Defined in:
lib/immosquare-constants/ip.rb

Overview

##

Simple class to provide dot notation access to IP addresses

##

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(local_ip, public_ip, client_ip) ⇒ IpResult

Returns a new instance of IpResult.



16
17
18
19
20
# File 'lib/immosquare-constants/ip.rb', line 16

def initialize(local_ip, public_ip, client_ip)
  @local  = local_ip
  @public = public_ip
  @client = client_ip
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



14
15
16
# File 'lib/immosquare-constants/ip.rb', line 14

def client
  @client
end

#localObject (readonly)

Returns the value of attribute local.



14
15
16
# File 'lib/immosquare-constants/ip.rb', line 14

def local
  @local
end

#publicObject (readonly)

Returns the value of attribute public.



14
15
16
# File 'lib/immosquare-constants/ip.rb', line 14

def public
  @public
end

Instance Method Details

#eachObject



54
55
56
# File 'lib/immosquare-constants/ip.rb', line 54

def each(&)
  to_hash.each(&)
end

#each_with_indexObject



58
59
60
# File 'lib/immosquare-constants/ip.rb', line 58

def each_with_index(&)
  to_hash.each_with_index(&)
end

#inspectObject



42
43
44
# File 'lib/immosquare-constants/ip.rb', line 42

def inspect
  "#<ImmosquareConstants::Ip::IpResult local: #{@local.inspect}, public: #{@public.inspect}, client: #{@client.inspect}>"
end

#to_aObject



46
47
48
# File 'lib/immosquare-constants/ip.rb', line 46

def to_a
  [@local, @public, @client]
end

#to_hObject



50
51
52
# File 'lib/immosquare-constants/ip.rb', line 50

def to_h
  to_hash
end

#to_hashObject



30
31
32
33
34
35
36
# File 'lib/immosquare-constants/ip.rb', line 30

def to_hash
  {
    :local  => @local,
    :public => @public,
    :client => @client
  }
end

#to_jsonObject



22
23
24
25
26
27
28
# File 'lib/immosquare-constants/ip.rb', line 22

def to_json(*)
  {
    :local  => @local,
    :public => @public,
    :client => @client
  }.to_json(*)
end

#to_sObject



38
39
40
# File 'lib/immosquare-constants/ip.rb', line 38

def to_s
  "local: #{@local}, public: #{@public}, client: #{@client}"
end