Class: MiniDisc::Discover::Service

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/minidisc/discover.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, host, options = {}) ⇒ Service

Returns a new instance of Service.



73
74
75
76
77
# File 'lib/minidisc/discover.rb', line 73

def initialize(id, host, options = {})
  @id = id
  @host = host
  @port = options.fetch(:port, 8080)
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



71
72
73
# File 'lib/minidisc/discover.rb', line 71

def host
  @host
end

#idObject (readonly)

Returns the value of attribute id.



71
72
73
# File 'lib/minidisc/discover.rb', line 71

def id
  @id
end

#portObject (readonly)

Returns the value of attribute port.



71
72
73
# File 'lib/minidisc/discover.rb', line 71

def port
  @port
end

Instance Method Details

#<=>(other) ⇒ Object



79
80
81
# File 'lib/minidisc/discover.rb', line 79

def <=>(other)
  to_h <=> other.to_h
end

#to_hObject



83
84
85
86
87
88
89
# File 'lib/minidisc/discover.rb', line 83

def to_h
  {
    id: @id,
    host: @host,
    port: @port
  }
end