Module: Writetheman::Article::Access
- Included in:
- Base
- Defined in:
- lib/writetheman/article/access.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#str_date ⇒ Object
readonly
Returns the value of attribute str_date.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #filemane_without_extension ⇒ Object
- #filename_from_title ⇒ Object
- #init_filename ⇒ Object
- #init_from_params(params) ⇒ Object
- #remove_access! ⇒ Object
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
5 6 7 |
# File 'lib/writetheman/article/access.rb', line 5 def date @date end |
#str_date ⇒ Object (readonly)
Returns the value of attribute str_date.
6 7 8 |
# File 'lib/writetheman/article/access.rb', line 6 def str_date @str_date end |
#title ⇒ Object
Returns the value of attribute title.
5 6 7 |
# File 'lib/writetheman/article/access.rb', line 5 def title @title end |
Instance Method Details
#filemane_without_extension ⇒ Object
31 32 33 |
# File 'lib/writetheman/article/access.rb', line 31 def filemane_without_extension @filename.match(/[^.]*/).to_s end |
#filename_from_title ⇒ Object
23 24 25 26 27 28 |
# File 'lib/writetheman/article/access.rb', line 23 def filename_from_title raise 'no title to init filename' if @title.nil? || @title.empty? raise 'no date to init filename' if @date.nil? name = convert_title_to_filename "#{format_date_file}-#{name}#{@extension}" end |
#init_filename ⇒ Object
8 9 10 11 12 |
# File 'lib/writetheman/article/access.rb', line 8 def init_filename raise 'no extension to init filename' if @extension.nil? || @extension.empty? @filename = filename_from_title if @filename.nil? || @filename.empty? @filename += @extension if !@filename.include?('.') end |
#init_from_params(params) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/writetheman/article/access.rb', line 14 def init_from_params(params) raise 'params are empty to init' if params.nil? || params.empty? remove_all! @header_params = params['header'] @title = @header_params['title'] @body = params['body'] @date = DateTime.now if @date.nil? end |
#remove_access! ⇒ Object
35 36 37 38 39 |
# File 'lib/writetheman/article/access.rb', line 35 def remove_access! @title = '' @date = nil @str_date = '' end |