Class: Workarea::StyleGuidesHelper::Partials

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/workarea/style_guides_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(root, scope, category) ⇒ Partials

Returns a new instance of Partials.



4
5
6
7
8
# File 'app/helpers/workarea/style_guides_helper.rb', line 4

def initialize(root, scope, category)
  @root = root
  @scope = scope
  @category = category
end

Instance Method Details

#name_from(path) ⇒ Object



21
22
23
24
25
# File 'app/helpers/workarea/style_guides_helper.rb', line 21

def name_from(path)
  path
    .gsub("#{@root}/app/views/", '')
    .gsub(/\/_(.+)\.html.*/, '/\1')
end

#patternObject



10
11
12
# File 'app/helpers/workarea/style_guides_helper.rb', line 10

def pattern
  "#{@root}/app/views/workarea/#{@scope}/style_guides/#{@category}/*.html*"
end

#to_aObject



14
15
16
17
18
19
# File 'app/helpers/workarea/style_guides_helper.rb', line 14

def to_a
  Dir[pattern]
    .map { |path| name_from(path) }
    .uniq
    .sort
end