Class: Surrounded::Context::RoleName

Inherits:
Object
  • Object
show all
Defined in:
lib/surrounded/context.rb

Instance Method Summary collapse

Constructor Details

#initialize(string, suffix = nil) ⇒ RoleName

Returns a new instance of RoleName.



283
284
285
286
287
288
289
290
291
292
# File 'lib/surrounded/context.rb', line 283

def initialize(string, suffix = nil)
  @string = string
    .to_s
    .split("_")
    .map { |part|
      part.capitalize
    }
    .join
    .sub(/_\d+/, "") + suffix.to_s
end

Instance Method Details

#to_strObject Also known as: to_s



294
295
296
# File 'lib/surrounded/context.rb', line 294

def to_str
  @string
end

#to_symObject



299
300
301
# File 'lib/surrounded/context.rb', line 299

def to_sym
  @string.to_sym
end