Class: JsonChecker::CheckableFile
- Inherits:
-
Object
- Object
- JsonChecker::CheckableFile
- Defined in:
- lib/json_checker/checkable_file.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#remotePath ⇒ Object
readonly
Returns the value of attribute remotePath.
Class Method Summary collapse
Instance Method Summary collapse
- #get_content ⇒ Object
-
#initialize(representation) ⇒ CheckableFile
constructor
A new instance of CheckableFile.
Constructor Details
#initialize(representation) ⇒ CheckableFile
Returns a new instance of CheckableFile.
8 9 10 11 12 |
# File 'lib/json_checker/checkable_file.rb', line 8 def initialize(representation) @name = representation['name'] @path = representation['path'] @remotePath = representation['remote-path'] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/json_checker/checkable_file.rb', line 6 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/json_checker/checkable_file.rb', line 6 def path @path end |
#remotePath ⇒ Object (readonly)
Returns the value of attribute remotePath.
6 7 8 |
# File 'lib/json_checker/checkable_file.rb', line 6 def remotePath @remotePath end |
Class Method Details
.is_valid_representation?(representation) ⇒ Boolean
14 15 16 17 18 19 20 |
# File 'lib/json_checker/checkable_file.rb', line 14 def self.is_valid_representation?(representation) json = JsonChecker::JSONFetcher.json_from_content(representation) unless json.nil? return (json.keys.include? 'name') && ((json.keys.include? 'path') || (json.keys.include? 'remote-path')) end return false end |
Instance Method Details
#get_content ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/json_checker/checkable_file.rb', line 22 def get_content() if @path.nil? && @remotePath.nil? puts "[ERROR] path or remote-path not found" return nil end unless @content.nil? return @content end @content = @path.nil? ? JSONFetcher.json_from_url(@remotePath) : JSONFetcher.json_from_path(@path) return @content end |