Class: Build::Name
- Inherits:
-
Object
- Object
- Build::Name
- Defined in:
- lib/build/name.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #header_guard(path) ⇒ Object
- #identifier ⇒ Object
-
#initialize(text) ⇒ Name
constructor
A new instance of Name.
- #macro(prefix = []) ⇒ Object
- #target ⇒ Object
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
#text ⇒ Object (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 |
#identifier ⇒ Object
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 |
#target ⇒ Object
37 38 39 |
# File 'lib/build/name.rb', line 37 def target @target ||= @text.gsub(/\s+/, '-').downcase end |