Class: Muwu::Helper::OutlineHelper

Inherits:
Object
  • Object
show all
Includes:
Muwu::Helper
Defined in:
lib/muwu/helper/outline_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(outline_fragment) ⇒ OutlineHelper

Returns a new instance of OutlineHelper.



9
10
11
# File 'lib/muwu/helper/outline_helper.rb', line 9

def initialize(outline_fragment)
  @outline_fragment = outline_fragment
end

Instance Method Details

#includes_navigatorObject



18
19
20
# File 'lib/muwu/helper/outline_helper.rb', line 18

def includes_navigator
  indicates_navigator || includes_navigator_in_array
end

#includes_navigator_in_arrayObject



23
24
25
# File 'lib/muwu/helper/outline_helper.rb', line 23

def includes_navigator_in_array
  (is_array) && (@outline_fragment.select{ |step| OutlineHelper.type_of(step) == :navigator }.any?)
end

#indicates_contentsObject



28
29
30
# File 'lib/muwu/helper/outline_helper.rb', line 28

def indicates_contents
  indicates_contents_hash || indicates_contents_string
end

#indicates_contents_hashObject



33
34
35
# File 'lib/muwu/helper/outline_helper.rb', line 33

def indicates_contents_hash
  (is_hash) && (RegexpLib.outline_contents =~ @outline_fragment.flatten[0])
end

#indicates_contents_stringObject



38
39
40
# File 'lib/muwu/helper/outline_helper.rb', line 38

def indicates_contents_string
  (is_string) && (RegexpLib.outline_contents =~ @outline_fragment)
end

#indicates_metadataObject



43
44
45
# File 'lib/muwu/helper/outline_helper.rb', line 43

def 
   || 
end

#indicates_metadata_hashObject



48
49
50
# File 'lib/muwu/helper/outline_helper.rb', line 48

def 
  (is_hash) && (RegexpLib. =~ @outline_fragment.flatten[0])
end

#indicates_metadata_stringObject



53
54
55
# File 'lib/muwu/helper/outline_helper.rb', line 53

def 
  (is_string) && (RegexpLib. =~ @outline_fragment)
end

#indicates_navigatorObject



58
59
60
# File 'lib/muwu/helper/outline_helper.rb', line 58

def indicates_navigator
  (is_string) && (RegexpLib.outline_navigator =~ @outline_fragment)
end

#indicates_outline_fragmentObject



63
64
65
# File 'lib/muwu/helper/outline_helper.rb', line 63

def indicates_outline_fragment
  is_array
end

#indicates_subcontentsObject



68
69
70
# File 'lib/muwu/helper/outline_helper.rb', line 68

def indicates_subcontents
  indicates_subcontents_hash || indicates_subcontents_string
end

#indicates_subcontents_hashObject



73
74
75
# File 'lib/muwu/helper/outline_helper.rb', line 73

def indicates_subcontents_hash
  (is_hash) && (RegexpLib.outline_subcontents =~ @outline_fragment.flatten[0])
end

#indicates_subcontents_stringObject



78
79
80
# File 'lib/muwu/helper/outline_helper.rb', line 78

def indicates_subcontents_string
  (is_string) && (RegexpLib.outline_subcontents =~ @outline_fragment)
end

#indicates_textObject



83
84
85
# File 'lib/muwu/helper/outline_helper.rb', line 83

def indicates_text
  (is_hash) && (RegexpLib.outline_text =~ @outline_fragment.flatten[0])
end

#indicates_titleObject



88
89
90
# File 'lib/muwu/helper/outline_helper.rb', line 88

def indicates_title
  indicates_title_hash || indicates_title_string
end

#indicates_title_hashObject



93
94
95
# File 'lib/muwu/helper/outline_helper.rb', line 93

def indicates_title_hash
  (is_hash) && (RegexpLib.outline_title =~ @outline_fragment.flatten[0])
end

#indicates_title_stringObject



98
99
100
# File 'lib/muwu/helper/outline_helper.rb', line 98

def indicates_title_string
  (is_string) && (RegexpLib.outline_title =~ @outline_fragment)
end

#is_arrayObject



103
104
105
# File 'lib/muwu/helper/outline_helper.rb', line 103

def is_array
  Array === @outline_fragment
end

#is_hashObject



108
109
110
# File 'lib/muwu/helper/outline_helper.rb', line 108

def is_hash
  Hash === @outline_fragment
end

#is_integerObject



113
114
115
# File 'lib/muwu/helper/outline_helper.rb', line 113

def is_integer
  Integer === @outline_fragment
end

#is_stringObject



118
119
120
# File 'lib/muwu/helper/outline_helper.rb', line 118

def is_string
  String === @outline_fragment
end

#text_step_flexible_suggests_fileObject



123
124
125
126
127
128
129
130
131
# File 'lib/muwu/helper/outline_helper.rb', line 123

def text_step_flexible_suggests_file
  if @outline_fragment.to_s =~ RegexpLib.file_ext_md
    true
  elsif @outline_fragment.to_s =~ RegexpLib.file_ext_haml
    true
  else
    false
  end
end