Module: Trybool

Defined in:
lib/trybool.rb,
lib/trybool/version.rb

Constant Summary collapse

TRUTHY_VALUES =
[
  true,
  1,
  "1",
  "t",
  "T",
  "true",
  "TRUE",
  "on",
  "ON",
]
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.<<(value) ⇒ Object



20
21
22
# File 'lib/trybool.rb', line 20

def self.<<(value)
  Array(value).each { |v| truthy_values << v }
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Trybool)

    the object that the method was called on



16
17
18
# File 'lib/trybool.rb', line 16

def self.configure
  yield(self)
end

.parse(value) ⇒ Object



24
25
26
# File 'lib/trybool.rb', line 24

def self.parse(value)
  truthy_values.include?(value)
end

.truthy_valuesObject



28
29
30
# File 'lib/trybool.rb', line 28

def self.truthy_values
  @truthy_values ||= Set[*TRUTHY_VALUES]
end