Class: Hipmost::Mattermost::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/hipmost/mattermost/channel.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, team:, display_name:, type:, header:) ⇒ Channel



12
13
14
15
16
17
18
# File 'lib/hipmost/mattermost/channel.rb', line 12

def initialize(name:, team:, display_name:, type:, header:)
  @name         = name.downcase.gsub(/\s/, "-")
  @team         = team
  @display_name = display_name
  @type         = type
  @header       = header
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/hipmost/mattermost/channel.rb', line 19

def name
  @name
end

Class Method Details

.from_hipchat(room, name:, team:) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/hipmost/mattermost/channel.rb', line 4

def self.from_hipchat(room, name:, team: )
  new(name:          name,
      type:          room.private? ? "P" : "O",
      display_name:  room.display_name,
      header:        room.topic,
      team:          team)
end

Instance Method Details

#to_jsonlObject



21
22
23
# File 'lib/hipmost/mattermost/channel.rb', line 21

def to_jsonl
  %[{ "type": "channel", "channel": { "team": "#{@team.name}", "name": "#@name", "display_name": "#@display_name", "type": "#@type", "header": "#@header" } }]
end