Class: Slk::Models::Channel
- Inherits:
-
Data
- Object
- Data
- Slk::Models::Channel
- Defined in:
- lib/slk/models/channel.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_archived ⇒ Object
readonly
Returns the value of attribute is_archived.
-
#is_im ⇒ Object
readonly
Returns the value of attribute is_im.
-
#is_mpim ⇒ Object
readonly
Returns the value of attribute is_mpim.
-
#is_private ⇒ Object
readonly
Returns the value of attribute is_private.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #display_name ⇒ Object
-
#dm? ⇒ Boolean
rubocop:enable Metrics/ParameterLists.
-
#initialize(id:, name: nil, is_private: false, is_im: false, is_mpim: false, is_archived: false) ⇒ Channel
constructor
rubocop:disable Metrics/ParameterLists.
- #public? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(id:, name: nil, is_private: false, is_im: false, is_mpim: false, is_archived: false) ⇒ Channel
rubocop:disable Metrics/ParameterLists
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/slk/models/channel.rb', line 18 def initialize(id:, name: nil, is_private: false, is_im: false, is_mpim: false, is_archived: false) super( id: id.to_s.freeze, name: name&.freeze, is_private: is_private, is_im: is_im, is_mpim: is_mpim, is_archived: is_archived ) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id
5 6 7 |
# File 'lib/slk/models/channel.rb', line 5 def id @id end |
#is_archived ⇒ Object (readonly)
Returns the value of attribute is_archived
5 6 7 |
# File 'lib/slk/models/channel.rb', line 5 def is_archived @is_archived end |
#is_im ⇒ Object (readonly)
Returns the value of attribute is_im
5 6 7 |
# File 'lib/slk/models/channel.rb', line 5 def is_im @is_im end |
#is_mpim ⇒ Object (readonly)
Returns the value of attribute is_mpim
5 6 7 |
# File 'lib/slk/models/channel.rb', line 5 def is_mpim @is_mpim end |
#is_private ⇒ Object (readonly)
Returns the value of attribute is_private
5 6 7 |
# File 'lib/slk/models/channel.rb', line 5 def is_private @is_private end |
#name ⇒ Object (readonly)
Returns the value of attribute name
5 6 7 |
# File 'lib/slk/models/channel.rb', line 5 def name @name end |
Class Method Details
.from_api(data) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/slk/models/channel.rb', line 6 def self.from_api(data) new( id: data['id'], name: data['name'] || data['name_normalized'], is_private: data['is_private'] || false, is_im: data['is_im'] || false, is_mpim: data['is_mpim'] || false, is_archived: data['is_archived'] || false ) end |
Instance Method Details
#display_name ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/slk/models/channel.rb', line 38 def display_name return name if name case id[0] when 'C' then '#channel' when 'G' then '#private' when 'D' then 'DM' else id end end |
#dm? ⇒ Boolean
rubocop:enable Metrics/ParameterLists
30 31 32 |
# File 'lib/slk/models/channel.rb', line 30 def dm? is_im || is_mpim end |
#public? ⇒ Boolean
34 35 36 |
# File 'lib/slk/models/channel.rb', line 34 def public? !is_private && !dm? end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/slk/models/channel.rb', line 49 def to_s dm? ? display_name : "##{name || id}" end |