Class: WhatTheGem::Command

Inherits:
Object show all
Defined in:
lib/whatthegem/commands.rb

Direct Known Subclasses

Changes, Help, Info, Stats, Usage

Defined Under Namespace

Classes: Meta

Constant Summary collapse

HEADER_TEMPLATE =

FIXME: It was > **info.info | paragraphs:1 }** but it looks weird due to tty-markdown bug: github.com/piotrmurach/tty-markdown/issues/11

Template.parse("# {{info.name}}\n> **{{info.info | paragraphs:1 | reflow }}**\n> ({{uris | join:\", \"}})\n\n## {{title}}\n\n\n")

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem) ⇒ Command

Returns a new instance of Command.



50
51
52
# File 'lib/whatthegem/commands.rb', line 50

def initialize(gem)
  @gem = gem
end

Class Attribute Details

.metaObject (readonly)

Returns the value of attribute meta.



12
13
14
# File 'lib/whatthegem/commands.rb', line 12

def meta
  @meta
end

Instance Attribute Details

#gemObject (readonly)

Returns the value of attribute gem.



48
49
50
# File 'lib/whatthegem/commands.rb', line 48

def gem
  @gem
end

Class Method Details

.call(*args) ⇒ Object



27
28
29
# File 'lib/whatthegem/commands.rb', line 27

def call(*args)
  new(*args).call
end

.get(handle) ⇒ Object



23
24
25
# File 'lib/whatthegem/commands.rb', line 23

def get(handle)
  Command.registry[handle]
end

.register(title: name.split('::').last, handle: title.downcase, description:) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/whatthegem/commands.rb', line 14

def register(title: name.split('::').last, handle: title.downcase, description:)
  Command.registry[handle] = self
  @meta = Meta.new(
    handle: handle,
    title: title,
    description: description
  )
end

Instance Method Details

#callObject



58
59
60
# File 'lib/whatthegem/commands.rb', line 58

def call
  puts full_output
end

#metaObject



54
55
56
# File 'lib/whatthegem/commands.rb', line 54

def meta
  self.class.meta
end