Class: TeamsConnector::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/teams_connector/builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Builder

Returns a new instance of Builder.

Yields:

  • (_self)

Yield Parameters:



7
8
9
# File 'lib/teams_connector/builder.rb', line 7

def initialize
  yield self
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/teams_connector/builder.rb', line 5

def content
  @content
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/teams_connector/builder.rb', line 5

def type
  @type
end

Class Method Details

.container(&block) ⇒ Object



20
21
22
# File 'lib/teams_connector/builder.rb', line 20

def self.container(&block)
  TeamsConnector::Builder.new { |entry| entry.container(&block) }
end

.facts(&block) ⇒ Object



30
31
32
# File 'lib/teams_connector/builder.rb', line 30

def self.facts(&block)
  TeamsConnector::Builder.new { |entry| entry.facts(&block) }
end

.text(text) ⇒ Object



11
12
13
# File 'lib/teams_connector/builder.rb', line 11

def self.text(text)
  TeamsConnector::Builder.new { |entry| entry.text text }
end

Instance Method Details

#container {|@content| ... } ⇒ Object

Yields:



24
25
26
27
28
# File 'lib/teams_connector/builder.rb', line 24

def container
  @type = :container
  @content = []
  yield @content
end

#facts {|@content| ... } ⇒ Object

Yields:



34
35
36
37
38
# File 'lib/teams_connector/builder.rb', line 34

def facts
  @type = :facts
  @content = {}
  yield @content
end

#resultObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/teams_connector/builder.rb', line 40

def result
  case @type
  when :container
    result_container
  when :facts
    result_facts
  when :text
    result_text
  else
    raise TypeError, "The type #{@type} is not supported by the TeamsConnector::Builder"
  end
end

#text(text) ⇒ Object



15
16
17
18
# File 'lib/teams_connector/builder.rb', line 15

def text(text)
  @type = :text
  @content = text
end