Class: SlackRubyBot::Commands::Support::Attrs

Inherits:
Object
  • Object
show all
Defined in:
lib/slack-ruby-bot/commands/support/attrs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Attrs

Returns a new instance of Attrs.



10
11
12
13
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 10

def initialize(klass)
  @klass = klass
  @commands = []
end

Instance Attribute Details

#command_descObject

Returns the value of attribute command_desc.



7
8
9
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 7

def command_desc
  @command_desc
end

#command_long_descObject

Returns the value of attribute command_long_desc.



7
8
9
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 7

def command_long_desc
  @command_long_desc
end

#command_nameObject

Returns the value of attribute command_name.



7
8
9
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 7

def command_name
  @command_name
end

#commandsObject (readonly)

Returns the value of attribute commands.



8
9
10
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 8

def commands
  @commands
end

#klassObject (readonly)

Returns the value of attribute klass.



8
9
10
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 8

def klass
  @klass
end

Instance Method Details

#command(title, &block) ⇒ Object



27
28
29
30
31
32
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 27

def command(title, &block)
  @commands << self.class.new(klass).tap do |k|
    k.title(title)
    k.instance_eval(&block)
  end
end

#desc(desc) ⇒ Object



19
20
21
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 19

def desc(desc)
  self.command_desc = desc
end

#long_desc(long_desc) ⇒ Object



23
24
25
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 23

def long_desc(long_desc)
  self.command_long_desc = long_desc
end

#title(title) ⇒ Object



15
16
17
# File 'lib/slack-ruby-bot/commands/support/attrs.rb', line 15

def title(title)
  self.command_name = title
end