Class: RailsHttpLab::Bruno::Document
- Inherits:
-
Object
- Object
- RailsHttpLab::Bruno::Document
- Defined in:
- lib/rails_http_lab/bruno/document.rb
Constant Summary collapse
- VERBS =
%w[get post put patch delete head options].freeze
Instance Attribute Summary collapse
-
#blocks ⇒ Object
Returns the value of attribute blocks.
-
#leading_blank_lines ⇒ Object
Returns the value of attribute leading_blank_lines.
-
#trailing_newline ⇒ Object
Returns the value of attribute trailing_newline.
Instance Method Summary collapse
- #block(name) ⇒ Object
- #blocks_named(name) ⇒ Object
- #http_method ⇒ Object
-
#initialize(blocks: [], leading_blank_lines: 0, trailing_newline: true) ⇒ Document
constructor
A new instance of Document.
- #url ⇒ Object
- #verb_block ⇒ Object
Constructor Details
#initialize(blocks: [], leading_blank_lines: 0, trailing_newline: true) ⇒ Document
Returns a new instance of Document.
7 8 9 10 11 |
# File 'lib/rails_http_lab/bruno/document.rb', line 7 def initialize(blocks: [], leading_blank_lines: 0, trailing_newline: true) @blocks = blocks @leading_blank_lines = leading_blank_lines @trailing_newline = trailing_newline end |
Instance Attribute Details
#blocks ⇒ Object
Returns the value of attribute blocks.
4 5 6 |
# File 'lib/rails_http_lab/bruno/document.rb', line 4 def blocks @blocks end |
#leading_blank_lines ⇒ Object
Returns the value of attribute leading_blank_lines.
5 6 7 |
# File 'lib/rails_http_lab/bruno/document.rb', line 5 def leading_blank_lines @leading_blank_lines end |
#trailing_newline ⇒ Object
Returns the value of attribute trailing_newline.
5 6 7 |
# File 'lib/rails_http_lab/bruno/document.rb', line 5 def trailing_newline @trailing_newline end |
Instance Method Details
#block(name) ⇒ Object
13 14 15 |
# File 'lib/rails_http_lab/bruno/document.rb', line 13 def block(name) blocks.find { |b| b.name == name } end |
#blocks_named(name) ⇒ Object
17 18 19 |
# File 'lib/rails_http_lab/bruno/document.rb', line 17 def blocks_named(name) blocks.select { |b| b.name == name } end |
#http_method ⇒ Object
27 28 29 |
# File 'lib/rails_http_lab/bruno/document.rb', line 27 def http_method verb_block&.name&.upcase end |
#url ⇒ Object
31 32 33 |
# File 'lib/rails_http_lab/bruno/document.rb', line 31 def url verb_block&.[]("url") end |
#verb_block ⇒ Object
23 24 25 |
# File 'lib/rails_http_lab/bruno/document.rb', line 23 def verb_block blocks.find { |b| VERBS.include?(b.name) } end |