Class: Wst::Content
Instance Method Summary
collapse
#config, config, #defaultLinks, defaultLinks, links_file_path, read_config, read_configuration, read_default_links, read_translations, translation_files, valid_location?
Constructor Details
#initialize(file_path, child = nil) ⇒ Content
Returns a new instance of Content.
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/content.rb', line 10
def initialize file_path, child = nil
@file_path = file_path
@plain_content = ""
@datas = Hash.new
@cats = ""
@child = child
@content = content
read_content
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/content.rb', line 37
def method_missing(m, *args, &block)
if m =~ /^(.*)\?$/
return @datas.has_key? $1
elsif @datas.has_key? m.to_s
return @datas[m.to_s]
else
return nil
end
end
|
Instance Method Details
#account(name) ⇒ Object
77
78
79
80
|
# File 'lib/content.rb', line 77
def account name
return nil unless account? name
return config["accounts"][name]
end
|
#account?(name) ⇒ Boolean
72
73
74
75
|
# File 'lib/content.rb', line 72
def account? name
return false unless config.has_key? "accounts"
return config["accounts"].has_key? name
end
|
#child ⇒ Object
21
22
23
|
# File 'lib/content.rb', line 21
def child
@child
end
|
#content ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/content.rb', line 25
def content
c = self
while !c.child.nil?
c = c.child
end
c
end
|
#datas ⇒ Object
59
60
61
|
# File 'lib/content.rb', line 59
def datas
@datas
end
|
#dir ⇒ Object
33
34
35
|
# File 'lib/content.rb', line 33
def dir
File.dirname @file_path
end
|
#gravatar ⇒ Object
67
68
69
70
|
# File 'lib/content.rb', line 67
def gravatar
hash = Digest::MD5.hexdigest(email)
"http://www.gravatar.com/avatar/#{hash}"
end
|
#gravatar? ⇒ Boolean
63
64
65
|
# File 'lib/content.rb', line 63
def gravatar?
email?
end
|
#raw_content ⇒ Object
47
48
49
|
# File 'lib/content.rb', line 47
def raw_content
@plain_content
end
|
#url ⇒ Object
55
56
57
|
# File 'lib/content.rb', line 55
def url
@url ||= ''
end
|
#url=(url) ⇒ Object
51
52
53
|
# File 'lib/content.rb', line 51
def url= url
@url = url
end
|