mirror of
https://github.com/danbee/micropub.git
synced 2025-03-04 08:59:13 +00:00
30 lines
420 B
Ruby
30 lines
420 B
Ruby
class PostJSONParser
|
|
def initialize(json)
|
|
@data = JSON.parse(json)
|
|
end
|
|
|
|
def params
|
|
{
|
|
"title" => title,
|
|
"content" => content,
|
|
"category" => category,
|
|
}.compact
|
|
end
|
|
|
|
private
|
|
|
|
attr_accessor :data
|
|
|
|
def title
|
|
data.dig("properties", "title", 0)
|
|
end
|
|
|
|
def content
|
|
data.dig("properties", "content", 0)
|
|
end
|
|
|
|
def category
|
|
data.dig("properties", "category")
|
|
end
|
|
end
|