Sha256: ac867c6e4c3984f5905b5175979b981da8ef826e5156220c1ff9152327504a82
Contents?: true
Size: 1.41 KB
Versions: 7
Compression:
Stored size: 1.41 KB
Contents
# # The !okay/news module for YAML.rb # require 'okay' module Okay class News < ModuleBase attr_accessor :title, :link, :description, :updatePeriod, :items def to_yaml_properties [ '@title', '@link', '@description', '@updatePeriod', '@items' ] end def to_yaml_type "!okay/news" end end Okay.add_type( "news" ) { |type, val, modules| Okay.object_maker( Okay::News, val, modules ) } class NewsItem < ModuleBase attr_accessor :title, :link, :description, :pubTime def to_yaml_properties [ '@title', '@link', '@description', '@pubTime' ] end def to_yaml_type "!okay/news/item" end end Okay.add_type( "news/item" ) { |type, val, modules| Okay.object_maker( Okay::NewsItem, val, modules ) } end Okay.load_schema( <<EOY ) # Schema for Okay::News types --- %YAML:1.0 !okay/schema okay/news: description: > Inspired by RSS, more limited... examples: > If I had a news site... schema: - map: /title: [ str ] /link: [ str ] /description: [ str ] /updatePeriod: [ str ] /items: - seq: { /*: [ okay/news/item ] } okay/news/item: description: > Inside okay/news lies... examples: > See okay/news examples... schema: - map: /title: [ str ] /pubTime: [ time ] /link: [ str ] /description: [ str ] optional: [ /title ] EOY
Version data entries
7 entries across 7 versions & 1 rubygems