Class: AskAwesomely::Design
- Inherits:
-
Object
- Object
- AskAwesomely::Design
- Defined in:
- lib/ask_awesomely/design.rb
Constant Summary collapse
- VALID_FONTS =
[ "Acme", "Arial", "Arvo", "Bangers", "Cabin", "Cabin Condensed", "Courier", "Crete Round", "Dancing Script", "Exo", "Georgia", "Handlee", "Karla", "Lato", "Lobster", "Lora", "McLaren", "Monsterrat", "Nixie", "Old Standard TT", "Open Sans", "Oswald", "Playfair", "Quicksand", "Raleway", "Signika", "Sniglet", "Source Sans Pro", "Vollkorn" ]
Instance Method Summary collapse
- #answer_color(color) ⇒ Object
- #background_color(color) ⇒ Object
- #button_color(color) ⇒ Object
- #font(font) ⇒ Object
- #id ⇒ Object
-
#initialize(&block) ⇒ Design
constructor
A new instance of Design.
- #question_color(color) ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(&block) ⇒ Design
Returns a new instance of Design.
36 37 38 39 |
# File 'lib/ask_awesomely/design.rb', line 36 def initialize(&block) @state = OpenStruct.new(colors: {}) instance_eval(&block) end |
Instance Method Details
#answer_color(color) ⇒ Object
53 54 55 |
# File 'lib/ask_awesomely/design.rb', line 53 def answer_color(color) @state.colors[:answer] = color end |
#background_color(color) ⇒ Object
45 46 47 |
# File 'lib/ask_awesomely/design.rb', line 45 def background_color(color) @state.colors[:background] = color end |
#button_color(color) ⇒ Object
57 58 59 |
# File 'lib/ask_awesomely/design.rb', line 57 def (color) @state.colors[:button] = color end |
#font(font) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/ask_awesomely/design.rb', line 61 def font(font) unless VALID_FONTS.include?(font) raise AskAwesomely::InvalidFontError, "#{font} is not supported; you must use one of the following fonts: #{VALID_FONTS.join(', ')}" end @state.font = font end |
#id ⇒ Object
41 42 43 |
# File 'lib/ask_awesomely/design.rb', line 41 def id @id ||= upload_to_typeform["id"] end |
#question_color(color) ⇒ Object
49 50 51 |
# File 'lib/ask_awesomely/design.rb', line 49 def question_color(color) @state.colors[:question] = color end |
#to_json ⇒ Object
69 70 71 72 73 74 |
# File 'lib/ask_awesomely/design.rb', line 69 def to_json(*) { colors: @state.colors, font: @state.font }.to_json end |