Class: Basis::My

Inherits:
Object
  • Object
show all
Defined in:
lib/basis/my.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ My

Returns a new instance of My.



8
9
10
11
12
13
14
15
# File 'lib/basis/my.rb', line 8

def initialize name
  @name      = name
  @path      = @name.tr "-", "/"
  @underpath = @path.tr "/", "_"

  @classname = @name.split("-").
    map { |a| a.split("_").map { |b| b.capitalize }.join }.join "::"
end

Instance Attribute Details

#classnameObject (readonly)

Returns the value of attribute classname.



3
4
5
# File 'lib/basis/my.rb', line 3

def classname
  @classname
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/basis/my.rb', line 4

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/basis/my.rb', line 5

def path
  @path
end

#underpathObject (readonly)

Returns the value of attribute underpath.



6
7
8
# File 'lib/basis/my.rb', line 6

def underpath
  @underpath
end

Instance Method Details

#to_hObject



17
18
19
20
21
22
23
24
# File 'lib/basis/my.rb', line 17

def to_h
  @hash ||= {
    "my.classname" => classname,
    "my.name"      => name,
    "my.path"      => path,
    "my.underpath" => underpath,
  }
end