Class: Statique::Mode

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(mode = MODE_SERVER) ⇒ Mode

Returns a new instance of Mode.

Raises:

  • (ArgumentError)


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

#buildObject



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

Returns:

  • (Boolean)


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

def build?
  @mode == MODE_BUILD
end

#serverObject



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

Returns:

  • (Boolean)


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

def server?
  @mode == MODE_SERVER
end