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.



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

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.



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

def client
  @client
end

#localObject (readonly)

Returns the value of attribute local.



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

def local
  @local
end

#publicObject (readonly)

Returns the value of attribute public.



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

def public
  @public
end

Instance Method Details

#inspectObject



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

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

#to_aObject



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

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

#to_hObject



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

def to_h
  to_hash
end

#to_hashObject



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

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

#to_jsonObject



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

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

#to_sObject



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

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