class Stringento::Placeholder

A placeholder is a to-be-resolved-and-formatted token within a string. A placeholder has a minimum one part and at maximum three parts (token::formatter:argument), for example:

Constants

SEPARATOR

Attributes

arg[R]
formatter[R]
name[R]
value[R]

Public Class Methods

new(value) click to toggle source
# File lib/stringento/placeholder.rb, line 22
def initialize(value)
  @value = value.to_s

  parts = @value.split(SEPARATOR)
  count = parts.length

  raise ArgumentError, "Cannot be split: #{value}" if count.negative? || count > 3

  @name       = parts[0] || ''
  @formatter  = parts[1] || ''
  @arg        = parts[2] || ''

  freeze
end