Class: Build::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/build/name.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Name

Returns a new instance of Name.



23
24
25
# File 'lib/build/name.rb', line 23

def initialize(text)
	@text = text
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



31
32
33
# File 'lib/build/name.rb', line 31

def text
  @text
end

Class Method Details

.from_target(string) ⇒ Object



27
28
29
# File 'lib/build/name.rb', line 27

def self.from_target(string)
	self.new(string.gsub(/(^|[ \-_])(.)/){" " + $2.upcase}.strip)
end

Instance Method Details

#header_guard(path) ⇒ Object



45
46
47
# File 'lib/build/name.rb', line 45

def header_guard(path)
	macro(path) + '_H'
end

#identifierObject



33
34
35
# File 'lib/build/name.rb', line 33

def identifier
	@identifier ||= @text.gsub(/\s+/, '')
end

#macro(prefix = []) ⇒ Object



41
42
43
# File 'lib/build/name.rb', line 41

def macro(prefix = [])
	(Array(prefix) + [@text]).collect{|name| name.upcase.gsub(/\s+/, '_')}.join('_')
end

#targetObject



37
38
39
# File 'lib/build/name.rb', line 37

def target
	@target ||= @text.gsub(/\s+/, '-').downcase
end