Class: HeyYou::Builder::Slack

Inherits:
Base
  • Object
show all
Defined in:
lib/hey_you/builder/slack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#icon_emojiObject (readonly)

Returns the value of attribute icon_emoji.



4
5
6
# File 'lib/hey_you/builder/slack.rb', line 4

def icon_emoji
  @icon_emoji
end

#icon_urlObject (readonly)

Returns the value of attribute icon_url.



4
5
6
# File 'lib/hey_you/builder/slack.rb', line 4

def icon_url
  @icon_url
end

#textObject (readonly)

Returns the value of attribute text.



4
5
6
# File 'lib/hey_you/builder/slack.rb', line 4

def text
  @text
end

#usernameObject (readonly)

Returns the value of attribute username.



4
5
6
# File 'lib/hey_you/builder/slack.rb', line 4

def username
  @username
end

#webhook_nameObject (readonly)

Returns the value of attribute webhook_name.



4
5
6
# File 'lib/hey_you/builder/slack.rb', line 4

def webhook_name
  @webhook_name
end

Instance Method Details

#buildObject



6
7
8
9
10
11
12
# File 'lib/hey_you/builder/slack.rb', line 6

def build
  @webhook_name = ch_data.fetch('webhook_name', nil)
  @username = ch_data.fetch('username', nil) || Config.config.slack.slack_username
  @text = interpolate(ch_data.fetch('text'), options)
  @icon_emoji = ch_data.fetch('icon_emoji', nil)
  @icon_url = ch_data.fetch('icon_url', nil)
end

#to_hashObject



14
15
16
17
18
19
20
21
22
# File 'lib/hey_you/builder/slack.rb', line 14

def to_hash
  excluded = [:@data, :@key, :@options]
  self.instance_variables.inject({}) do |memo, var|
    unless excluded.include?(var)
      memo[var.to_s.gsub('@', '')] = instance_variable_get(var)
    end
    memo
  end
end