Class: Statique::Mode
- Inherits:
-
Object
- Object
- Statique::Mode
- Defined in:
- lib/statique/mode.rb
Constant Summary collapse
- MODE_BUILD =
"build"
- MODE_SERVER =
"server"
- MODES =
[MODE_BUILD, MODE_SERVER].freeze
Instance Method Summary collapse
- #build ⇒ Object
- #build! ⇒ Object
- #build? ⇒ Boolean
-
#initialize(mode = MODE_SERVER) ⇒ Mode
constructor
A new instance of Mode.
- #server ⇒ Object
- #server! ⇒ Object
- #server? ⇒ Boolean
Constructor Details
#initialize(mode = MODE_SERVER) ⇒ Mode
Returns a new instance of Mode.
9 10 11 12 13 14 |
# File 'lib/statique/mode.rb', line 9 def initialize(mode = MODE_SERVER) raise ArgumentError, "Mode can't be empty" if mode.nil? || mode.empty? raise ArgumentError, "Mode must be one of #{MODES}" unless MODES.include?(mode.to_s) @mode = mode == MODE_SERVER ? MODE_SERVER : MODE_BUILD end |
Instance Method Details
#build ⇒ Object
36 37 38 |
# File 'lib/statique/mode.rb', line 36 def build yield if build? end |
#build! ⇒ Object
20 21 22 |
# File 'lib/statique/mode.rb', line 20 def build! @mode = MODE_BUILD end |
#build? ⇒ Boolean
28 29 30 |
# File 'lib/statique/mode.rb', line 28 def build? @mode == MODE_BUILD end |
#server ⇒ Object
32 33 34 |
# File 'lib/statique/mode.rb', line 32 def server yield if server? end |
#server! ⇒ Object
16 17 18 |
# File 'lib/statique/mode.rb', line 16 def server! @mode = MODE_SERVER end |
#server? ⇒ Boolean
24 25 26 |
# File 'lib/statique/mode.rb', line 24 def server? @mode == MODE_SERVER end |