Class: Stella::Client::Container

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(usecase) ⇒ Container

Returns a new instance of Container.



203
204
205
# File 'lib/stella/client.rb', line 203

def initialize(usecase)
  @usecase = usecase
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



202
203
204
# File 'lib/stella/client.rb', line 202

def response
  @response
end

#usecaseObject

Returns the value of attribute usecase.



201
202
203
# File 'lib/stella/client.rb', line 201

def usecase
  @usecase
end

Class Method Details

.const_missing(const, *args) ⇒ Object



207
208
209
# File 'lib/stella/client.rb', line 207

def self.const_missing(const, *args)
  ResponseError.new(const)
end

Instance Method Details

#bodyObject



223
# File 'lib/stella/client.rb', line 223

def body; @response.body.content; end

#docObject



211
212
213
214
215
216
217
218
219
220
221
# File 'lib/stella/client.rb', line 211

def doc
  # NOTE: It's important to parse the document on every 
  # request because this container is available for the
  # entire life of a usecase. 
  case @response.header['Content-Type']
  when ['text/html']
    Nokogiri::HTML(body)
  when ['text/yaml']
    YAML.load(body)
  end
end

#headersObject Also known as: header



224
# File 'lib/stella/client.rb', line 224

def headers; @response.header; end

#quit(msg = nil) ⇒ Object



230
# File 'lib/stella/client.rb', line 230

def quit(msg=nil); Quit.new(msg); end

#repeat(t = 1) ⇒ Object



231
# File 'lib/stella/client.rb', line 231

def repeat(t=1); Repeat.new(t); end

#resource(n) ⇒ Object



228
# File 'lib/stella/client.rb', line 228

def resource(n);    usecase.resource n;    end

#set(n, v) ⇒ Object



227
# File 'lib/stella/client.rb', line 227

def set(n, v); usecase.resource n, v; end

#statusObject



226
# File 'lib/stella/client.rb', line 226

def status; @response.status; end

#wait(t) ⇒ Object



229
# File 'lib/stella/client.rb', line 229

def wait(t); sleep t; end