forked from tutsplus/ruby-refactoring
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35aadd1
commit 087f3c9
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class Post | ||
|
||
attr_reader :title, :date | ||
|
||
def initialize title, date | ||
@title = title | ||
@date = date | ||
end | ||
|
||
def body | ||
<<-RETURN | ||
RANDOM TEXT Ladyship it daughter securing procured or am moreover mr. Put | ||
sir she exercise vicinity cheerful wondered. Continual say suspicion | ||
provision you neglected sir curiosity unwilling. | ||
RETURN | ||
|
||
end | ||
|
||
def condensed_format | ||
metadata | ||
end | ||
|
||
def full_format | ||
return_string = metadata | ||
return_string << "--\n#{body}" | ||
|
||
return_string | ||
end | ||
|
||
private | ||
|
||
def metadata | ||
return_string = '' | ||
return_string << "Title: #{title}" | ||
return_string << "Date: #{date.strftime "%Y/%m/%d"}" | ||
|
||
return_string | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
class Post | ||
|
||
attr_reader :title, :date | ||
|
||
def initialize title, date | ||
@title = title | ||
@date = date | ||
end | ||
|
||
def body | ||
<<-RETURN | ||
RANDOM TEXT Ladyship it daughter securing procured or am moreover mr. Put | ||
sir she exercise vicinity cheerful wondered. Continual say suspicion | ||
provision you neglected sir curiosity unwilling. | ||
RETURN | ||
|
||
end | ||
|
||
def condensed_format | ||
return_string = '' | ||
return_string << "Title: #{title}" | ||
return_string << "Date: #{date.strftime "%Y/%m/%d"}" | ||
|
||
return_string | ||
end | ||
|
||
def full_format | ||
return_string = '' | ||
return_string << "Title: #{title}" | ||
return_string << "Date: #{date.strftime "%Y/%m/%d"}" | ||
return_string << "--\n#{body}" | ||
|
||
return_string | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters