Class: Arigato::View

Inherits:
Object
  • Object
show all
Defined in:
lib/arigato/view.rb

Constant Summary collapse

TITLE =
'Special Thanks'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(theme, gemfile = './Gemfile', layout = true) ⇒ View

Returns a new instance of View.



10
11
12
13
14
15
# File 'lib/arigato/view.rb', line 10

def initialize(theme, gemfile = './Gemfile', layout = true) 
  @theme = theme
  @specs = Arigato.specs(gemfile)
  @layout = layout
  @title = TITLE
end

Instance Attribute Details

#layoutObject

Returns the value of attribute layout.



8
9
10
# File 'lib/arigato/view.rb', line 8

def layout
  @layout
end

#specsObject

Returns the value of attribute specs.



8
9
10
# File 'lib/arigato/view.rb', line 8

def specs
  @specs
end

#themeObject

Returns the value of attribute theme.



8
9
10
# File 'lib/arigato/view.rb', line 8

def theme
  @theme
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/arigato/view.rb', line 8

def title
  @title
end

Class Method Details

.author(spec) ⇒ Object



62
63
64
# File 'lib/arigato/view.rb', line 62

def self.author(spec)
  spec.author ? "by #{spec.author}" : ''
end

Instance Method Details

#contentObject



29
30
31
# File 'lib/arigato/view.rb', line 29

def content
  erb(content_file).result(binding)
end

#content_fileObject



47
48
49
# File 'lib/arigato/view.rb', line 47

def content_file
  file('content')
end

#content_for(title = nil) ⇒ Object



59
60
# File 'lib/arigato/view.rb', line 59

def content_for(title = nil)
end

#erb(path) ⇒ Object



37
38
39
40
41
# File 'lib/arigato/view.rb', line 37

def erb(path)
  erb = ERB.new(File.read(path), nil, '-')
  erb.filename = path
  erb 
end

#layout_fileObject



51
52
53
# File 'lib/arigato/view.rb', line 51

def layout_file
  file('layout')
end


55
56
57
# File 'lib/arigato/view.rb', line 55

def link_to(label, href, target = '_blank')
  %!<a href="#{href}" target="#{target}">#{label}</a>!
end

#renderObject



17
18
19
# File 'lib/arigato/view.rb', line 17

def render 
  @layout ? render_with_layout : render_without_layout
end

#render_with_layoutObject



25
26
27
# File 'lib/arigato/view.rb', line 25

def render_with_layout
  layout
end

#render_without_layoutObject



21
22
23
# File 'lib/arigato/view.rb', line 21

def render_without_layout
  content
end

#theme_dirObject



43
44
45
# File 'lib/arigato/view.rb', line 43

def theme_dir
  Pathname.new(File.join(Arigato.themes_dir, theme))
end