Class: Jekyll::AwesomeNav::NavFileOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/awesome_nav/nav_file_options.rb

Constant Summary collapse

UNSET =
Object.new.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(append_unmatched: UNSET, hide: UNSET, ignore: UNSET, sort: UNSET) ⇒ NavFileOptions

Returns a new instance of NavFileOptions.



19
20
21
22
23
24
# File 'lib/jekyll/awesome_nav/nav_file_options.rb', line 19

def initialize(append_unmatched: UNSET, hide: UNSET, ignore: UNSET, sort: UNSET)
  @append_unmatched = append_unmatched
  @hide = hide
  @ignore_patterns = ignore == UNSET ? UNSET : normalize_ignore_patterns(ignore)
  @sort_options = sort == UNSET ? UNSET : SortOptions.from(sort)
end

Instance Attribute Details

#ignore_patternsObject (readonly)

Returns the value of attribute ignore_patterns.



8
9
10
# File 'lib/jekyll/awesome_nav/nav_file_options.rb', line 8

def ignore_patterns
  @ignore_patterns
end

#sort_optionsObject (readonly)

Returns the value of attribute sort_options.



8
9
10
# File 'lib/jekyll/awesome_nav/nav_file_options.rb', line 8

def sort_options
  @sort_options
end

Class Method Details

.from(data) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/jekyll/awesome_nav/nav_file_options.rb', line 10

def self.from(data)
  new(
    append_unmatched: data.key?("append_unmatched") ? data["append_unmatched"] : UNSET,
    hide: data.key?("hide") ? data["hide"] : UNSET,
    ignore: data.key?("ignore") ? data["ignore"] : UNSET,
    sort: data.key?("sort") ? data["sort"] : UNSET
  )
end

Instance Method Details

#append_unmatched_or(inherited) ⇒ Object



26
27
28
29
30
# File 'lib/jekyll/awesome_nav/nav_file_options.rb', line 26

def append_unmatched_or(inherited)
  return inherited if @append_unmatched == UNSET

  !!@append_unmatched
end

#hide?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/jekyll/awesome_nav/nav_file_options.rb', line 44

def hide?
  @hide != UNSET && !!@hide
end

#ignore_patterns_or(inherited) ⇒ Object



32
33
34
35
36
# File 'lib/jekyll/awesome_nav/nav_file_options.rb', line 32

def ignore_patterns_or(inherited)
  return inherited if @ignore_patterns == UNSET

  @ignore_patterns
end

#sort_options_or(inherited) ⇒ Object



38
39
40
41
42
# File 'lib/jekyll/awesome_nav/nav_file_options.rb', line 38

def sort_options_or(inherited)
  return inherited if @sort_options == UNSET

  @sort_options
end