Class: Stella::Client::Container
- Inherits:
-
Object
- Object
- Stella::Client::Container
- Defined in:
- lib/stella/client.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
-
#usecase ⇒ Object
Returns the value of attribute usecase.
Class Method Summary collapse
Instance Method Summary collapse
- #body ⇒ Object
- #doc ⇒ Object
- #headers ⇒ Object (also: #header)
-
#initialize(usecase) ⇒ Container
constructor
A new instance of Container.
- #quit(msg = nil) ⇒ Object
- #repeat(t = 1) ⇒ Object
- #resource(n) ⇒ Object
- #set(n, v) ⇒ Object
- #status ⇒ Object
- #wait(t) ⇒ Object
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
#response ⇒ Object
Returns the value of attribute response.
202 203 204 |
# File 'lib/stella/client.rb', line 202 def response @response end |
#usecase ⇒ Object
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
#body ⇒ Object
223 |
# File 'lib/stella/client.rb', line 223 def body; @response.body.content; end |
#doc ⇒ Object
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 |
#headers ⇒ Object 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 |
#status ⇒ Object
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 |