Class: Jekyll::Commands::RenameMovementInfo

Inherits:
Jekyll::Compose::FileInfo show all
Defined in:
lib/jekyll/commands/rename.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Jekyll::Compose::FileInfo

#content, #file_name

Constructor Details

#initialize(params) ⇒ RenameMovementInfo

Returns a new instance of RenameMovementInfo.



94
95
96
# File 'lib/jekyll/commands/rename.rb', line 94

def initialize(params)
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



93
94
95
# File 'lib/jekyll/commands/rename.rb', line 93

def params
  @params
end

Instance Method Details

#fromObject



98
99
100
# File 'lib/jekyll/commands/rename.rb', line 98

def from
  params.path
end

#front_matter(data) ⇒ Object



120
121
122
123
124
# File 'lib/jekyll/commands/rename.rb', line 120

def front_matter(data)
  data["title"] = params.title
  data["date"] = time_stamp if @params.touch?
  data
end

#resource_typeObject



102
103
104
105
106
107
108
109
110
# File 'lib/jekyll/commands/rename.rb', line 102

def resource_type
  if @params.post?
    "post"
  elsif @params.draft?
    "draft"
  else
    "file"
  end
end

#toObject



112
113
114
115
116
117
118
# File 'lib/jekyll/commands/rename.rb', line 112

def to
  if @params.post?
    File.join(@params.dirname, "#{date_stamp}-#{file_name}")
  else
    File.join(@params.dirname, file_name)
  end
end