Class: Brewscribe::Style

Inherits:
Object
  • Object
show all
Includes:
Conversion
Defined in:
lib/brewscribe/style.rb

Constant Summary collapse

TYPES =
['Ale', 'Lager', 'Mixed', 'Mead', 'Cider', 'Wheat']
KEY_CONVERSION =
{
  last_modified: DATE_CONV,
  min_og: FLOAT_CONV,
  max_og: FLOAT_CONV,
  min_fg: FLOAT_CONV,
  max_fg: FLOAT_CONV,
  number: INT_CONV,
  min_ibu: FLOAT_CONV,
  max_ibu: FLOAT_CONV,
  letter: ->(k) { Array('A'..'Z')[k.to_i-1] },
  type: ->(k) { TYPES[k.to_i] },
  min_abv: PERCENT_CONV,
  max_abv: PERCENT_CONV,
  min_color: FLOAT_CONV,
  max_color: FLOAT_CONV,
  examples: ->(k) { k.split(', ') }
}

Constants included from Conversion

Conversion::BOOLEAN_CONV, Conversion::DATE_CONV, Conversion::FLOAT_CONV, Conversion::INT_CONV, Conversion::PERCENT_CONV

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Conversion

#data_to_properties

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def category
  @category
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def description
  @description
end

#examplesObject

Returns the value of attribute examples.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def examples
  @examples
end

#guideObject

Returns the value of attribute guide.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def guide
  @guide
end

#ingredientsObject

Returns the value of attribute ingredients.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def ingredients
  @ingredients
end

#last_modifiedObject

Returns the value of attribute last_modified.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def last_modified
  @last_modified
end

#letterObject

Returns the value of attribute letter.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def letter
  @letter
end

#max_abvObject

Returns the value of attribute max_abv.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def max_abv
  @max_abv
end

#max_carbObject

Returns the value of attribute max_carb.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def max_carb
  @max_carb
end

#max_colorObject

Returns the value of attribute max_color.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def max_color
  @max_color
end

#max_fgObject

Returns the value of attribute max_fg.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def max_fg
  @max_fg
end

#max_ibuObject

Returns the value of attribute max_ibu.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def max_ibu
  @max_ibu
end

#max_ogObject

Returns the value of attribute max_og.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def max_og
  @max_og
end

#min_abvObject

Returns the value of attribute min_abv.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def min_abv
  @min_abv
end

#min_carbObject

Returns the value of attribute min_carb.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def min_carb
  @min_carb
end

#min_colorObject

Returns the value of attribute min_color.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def min_color
  @min_color
end

#min_fgObject

Returns the value of attribute min_fg.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def min_fg
  @min_fg
end

#min_ibuObject

Returns the value of attribute min_ibu.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def min_ibu
  @min_ibu
end

#min_ogObject

Returns the value of attribute min_og.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def min_og
  @min_og
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def name
  @name
end

#numberObject

Returns the value of attribute number.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def number
  @number
end

#profileObject

Returns the value of attribute profile.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def profile
  @profile
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def type
  @type
end

Returns the value of attribute web_link.



3
4
5
# File 'lib/brewscribe/style.rb', line 3

def web_link
  @web_link
end

Class Method Details

.from_data(data) ⇒ Object



30
31
32
33
34
35
# File 'lib/brewscribe/style.rb', line 30

def self.from_data data
  style = new
  style.data_to_properties data

  style
end