Class: OsCtl::Client::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/osctl/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(resp) ⇒ Response

Returns a new instance of Response



11
12
13
# File 'lib/osctl/client.rb', line 11

def initialize(resp)
  @resp = resp
end

Instance Method Details

#[](k) ⇒ Object



35
36
37
# File 'lib/osctl/client.rb', line 35

def [](k)
  data[k]
end

#dataObject



31
32
33
# File 'lib/osctl/client.rb', line 31

def data
  @resp[:response]
end

#each(&block) ⇒ Object



39
40
41
# File 'lib/osctl/client.rb', line 39

def each(&block)
  data.each(&block)
end

#error?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/osctl/client.rb', line 19

def error?
  !ok?
end

#messageObject



27
28
29
# File 'lib/osctl/client.rb', line 27

def message
  update? ? @resp[:progress] : @resp[:message]
end

#ok?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/osctl/client.rb', line 15

def ok?
  @resp[:status] == true
end

#update?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/osctl/client.rb', line 23

def update?
  ok? && @resp.has_key?(:progress)
end