Module: Middleman::Presentation::ComparableSlide

Includes:
Comparable
Included in:
ExistingSlide, NewSlide
Defined in:
lib/middleman-presentation-core/comparable_slide.rb

Overview

All methods needed to compare slides

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



24
25
26
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 24

def <=>(other)
  path <=> other.path
end

#base_nameObject

Needs to be implemented to make the other methods work



14
15
16
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 14

def base_name
  fail MethodNotImplemented
end

#base_name?(b) ⇒ Boolean

Check if basename is equal

Returns:

  • (Boolean)


64
65
66
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 64

def base_name?(b)
  base_name == b
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 29

def eql?(other)
  path.eql? other.path
end

#groupObject

Needs to be implemented to make the other methods work



19
20
21
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 19

def group
  fail MethodNotImplemented
end

#group?(g) ⇒ Boolean

Checks if slide is in group

Returns:

  • (Boolean)


46
47
48
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 46

def group?(g)
  group == g
end

#hashObject



41
42
43
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 41

def hash
  path.hash
end

#match?(string_or_regex) ⇒ Boolean

Check if string/regex matches path

Returns:

  • (Boolean)


51
52
53
54
55
56
57
58
59
60
61
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 51

def match?(string_or_regex)
  regex = if string_or_regex.is_a? String
            Regexp.new(string_or_regex)
          else
            string_or_regex
          end

  # rubocop:disable Style/CaseEquality
  regex === relative_path.to_s
  # rubocop:enable Style/CaseEquality
end

#pathObject

Needs to be implemented to make the other methods work



9
10
11
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 9

def path
  fail MethodNotImplemented
end

#similar?(other) ⇒ Boolean

Is slide similar to another slide

Returns:

  • (Boolean)


34
35
36
37
38
# File 'lib/middleman-presentation-core/comparable_slide.rb', line 34

def similar?(other)
  return true if eql? other

  base_name?(other.base_name) && group?(other.group)
end