Module: AocCli::Concerns::LocationConcern

Included in:
ApplicationController
Defined in:
lib/aoc_cli/controllers/concerns/location_concern.rb

Instance Method Summary collapse

Instance Method Details

#current_eventObject



12
13
14
15
16
17
# File 'lib/aoc_cli/controllers/concerns/location_concern.rb', line 12

def current_event
  case current_resource
  when Event then current_resource
  when Puzzle then current_resource.event
  end
end

#current_locationObject



8
9
10
# File 'lib/aoc_cli/controllers/concerns/location_concern.rb', line 8

def current_location
  Location.first(path: current_path)
end

#current_pathObject



4
5
6
# File 'lib/aoc_cli/controllers/concerns/location_concern.rb', line 4

def current_path
  File.expand_path(".")
end

#current_puzzleObject



19
20
21
22
23
# File 'lib/aoc_cli/controllers/concerns/location_concern.rb', line 19

def current_puzzle
  case current_resource
  when Puzzle then current_resource
  end
end

#ensure_in_aoc_dir!Object



37
38
39
40
41
# File 'lib/aoc_cli/controllers/concerns/location_concern.rb', line 37

def ensure_in_aoc_dir!
  return true if in_aoc_dir?

  render_error!(ERRORS[:not_in_aoc])
end

#ensure_in_event_dir!Object



25
26
27
28
29
# File 'lib/aoc_cli/controllers/concerns/location_concern.rb', line 25

def ensure_in_event_dir!
  return true if in_event_dir?

  render_error!(ERRORS[:not_in_event])
end

#ensure_in_puzzle_dir!Object



31
32
33
34
35
# File 'lib/aoc_cli/controllers/concerns/location_concern.rb', line 31

def ensure_in_puzzle_dir!
  return true if in_puzzle_dir?

  render_error!(ERRORS[:not_in_puzzle])
end

#ensure_not_in_aoc_dir!Object



43
44
45
46
47
# File 'lib/aoc_cli/controllers/concerns/location_concern.rb', line 43

def ensure_not_in_aoc_dir!
  return true unless in_aoc_dir?

  render_error!(ERRORS[:in_aoc])
end