Class: Gemsmith::Aids::Gem

Inherits:
Object
  • Object
show all
Defined in:
lib/gemsmith/aids/gem.rb

Overview

Parses a raw string into a valid gem and/or class name which can be used to construct gem skeletons and related Ruby objects.

Instance Method Summary collapse

Constructor Details

#initialize(string = "unknown", util: Thor::Util) ⇒ Gem

Returns a new instance of Gem.



6
7
8
9
# File 'lib/gemsmith/aids/gem.rb', line 6

def initialize string = "unknown", util: Thor::Util
  @string = string
  @util = util
end

Instance Method Details

#klassObject



15
16
17
# File 'lib/gemsmith/aids/gem.rb', line 15

def klass
  @klass ||= util.camel_case name
end

#nameObject



11
12
13
# File 'lib/gemsmith/aids/gem.rb', line 11

def name
  @name ||= util.snake_case(string).tr(" ", "_").tr "-", "_"
end