Class: HaveAPI::Example

Inherits:
Object
  • Object
show all
Defined in:
lib/haveapi/example.rb

Instance Method Summary collapse

Constructor Details

#initialize(title) ⇒ Example

Returns a new instance of Example.



3
4
5
# File 'lib/haveapi/example.rb', line 3

def initialize(title)
  @title = title
end

Instance Method Details

#comment(str) ⇒ Object



15
16
17
# File 'lib/haveapi/example.rb', line 15

def comment(str)
  @comment = str
end

#describeObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/haveapi/example.rb', line 23

def describe
  if provided?
    {
        title: @title,
        request: @request,
        response: @response,
        comment: @comment
    }
  else
    {}
  end
end

#provided?Boolean

Returns:



19
20
21
# File 'lib/haveapi/example.rb', line 19

def provided?
  @request || @response || @comment
end

#request(f) ⇒ Object



7
8
9
# File 'lib/haveapi/example.rb', line 7

def request(f)
  @request = f
end

#response(f) ⇒ Object



11
12
13
# File 'lib/haveapi/example.rb', line 11

def response(f)
  @response = f
end