class Build::Name
Attributes
text[R]
Public Class Methods
from_target(string)
click to toggle source
# File lib/build/name.rb, line 31 def self.from_target(string) self.new(string.gsub(/(^|[ \-_])(.)/){" " + $2.upcase}.strip) end
new(text)
click to toggle source
# File lib/build/name.rb, line 23 def initialize(text) @text = text @identifier = nil @target = nil @key = nil end
Public Instance Methods
header_guard(path)
click to toggle source
@return [String] suitable for C header guard macro.
# File lib/build/name.rb, line 58 def header_guard(path) macro(path) + '_H' end
identifier()
click to toggle source
@return [String] suitable for constant identifier.
# File lib/build/name.rb, line 38 def identifier @identifier ||= @text.gsub(/\s+/, '') end
key(*postfix)
click to toggle source
@return [String] suitable for variable name.
# File lib/build/name.rb, line 48 def key(*postfix) @key ||= ([@text] + postfix).collect{|part| part.downcase.gsub(/\s+/, '_')}.join('_') end
macro(prefix = [])
click to toggle source
@return [String] suitable for C macro name.
# File lib/build/name.rb, line 53 def macro(prefix = []) (Array(prefix) + [@text]).collect{|name| name.upcase.gsub(/\s+/, '_')}.join('_') end
target()
click to toggle source
@return [String] suitable for target name.
# File lib/build/name.rb, line 43 def target @target ||= @text.gsub(/\s+/, '-').downcase end