Class: Blossom::Application::Configuration::Value

Inherits:
Struct
  • Object
show all
Defined in:
lib/blossom.rb

Instance Method Summary collapse

Instance Method Details

#booleanObject



221
222
223
224
225
226
227
# File 'lib/blossom.rb', line 221

def boolean
  if value == true or value == false
    value
  else
    fail "Must be \`yes' or \`no\': #{name}"
  end
end

#durationObject



229
230
231
232
233
234
235
# File 'lib/blossom.rb', line 229

def duration
  if value =~ /^((?:\d+\.)?\d+) ([a-z]+?)s?$/
    $1.to_f * time_unit($2.to_sym)
  else
    error "Bad duration: #{value}"
  end
end

#stringObject



213
214
215
# File 'lib/blossom.rb', line 213

def string
  value.to_s
end

#wordsObject



217
218
219
# File 'lib/blossom.rb', line 217

def words
  value.gsub(/^\s+|\s$/, "").split(/\s+/)
end