Class: Onebox::Engine::GithubGistOnebox::GistFile
- Inherits:
-
Object
- Object
- Onebox::Engine::GithubGistOnebox::GistFile
- Defined in:
- lib/onebox/engine/github_gist_onebox.rb
Constant Summary collapse
- MAX_LINES =
10
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(json) ⇒ GistFile
constructor
A new instance of GistFile.
- #truncated? ⇒ Boolean
Constructor Details
#initialize(json) ⇒ GistFile
Returns a new instance of GistFile.
57 58 59 60 61 |
# File 'lib/onebox/engine/github_gist_onebox.rb', line 57 def initialize(json) @json = json @filename = @json["filename"] @language = @json["language"] end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
52 53 54 |
# File 'lib/onebox/engine/github_gist_onebox.rb', line 52 def filename @filename end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
53 54 55 |
# File 'lib/onebox/engine/github_gist_onebox.rb', line 53 def language @language end |
Instance Method Details
#content ⇒ Object
63 64 65 |
# File 'lib/onebox/engine/github_gist_onebox.rb', line 63 def content lines.take(MAX_LINES).join("\n") end |
#truncated? ⇒ Boolean
67 68 69 |
# File 'lib/onebox/engine/github_gist_onebox.rb', line 67 def truncated? lines.size > MAX_LINES end |