Module: Staticky::Resources::Plugins::Prelude::InstanceMethods

Defined in:
lib/staticky/resources/plugins/prelude.rb

Instance Method Summary collapse

Instance Method Details

#basenameObject



26
27
28
# File 'lib/staticky/resources/plugins/prelude.rb', line 26

def basename
  root? ? "index.html" : "#{url}.html"
end

#destinationObject



40
41
42
# File 'lib/staticky/resources/plugins/prelude.rb', line 40

def destination
  @destination ||= Staticky.build_path
end

#destination=(destination) ⇒ Object



44
45
46
# File 'lib/staticky/resources/plugins/prelude.rb', line 44

def destination=(destination)
  @destination = Pathname(destination)
end

#filepathObject



18
19
20
# File 'lib/staticky/resources/plugins/prelude.rb', line 18

def filepath
  destination.join(basename)
end

#readObject



22
23
24
# File 'lib/staticky/resources/plugins/prelude.rb', line 22

def read
  filepath.read
end

#root?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/staticky/resources/plugins/prelude.rb', line 30

def root?
  url == "/"
end

#uriObject

Raises:

  • (ArgumentError)


34
35
36
37
38
# File 'lib/staticky/resources/plugins/prelude.rb', line 34

def uri
  return @uri if defined?(@uri)

  raise ArgumentError, "url is required"
end

#urlObject

Raises:

  • (ArgumentError)


48
49
50
51
52
# File 'lib/staticky/resources/plugins/prelude.rb', line 48

def url
  return @url if defined?(@url)

  raise ArgumentError, "url is required"
end

#url=(url) ⇒ Object



54
55
56
57
# File 'lib/staticky/resources/plugins/prelude.rb', line 54

def url=(url)
  @url = url
  @uri = parse_url(url)
end